while 累乘

单选题 难度 2

#while#loop

算的是几的阶乘?

题目

下面代码的输出是( )。

int n = 1, p = 1;
while (n <= 4) { p *= n; n++; }
cout << p << endl;
  1. 24
  2. 10
  3. 120
  4. 6
来小码星球,动手写一遍 →