#3214. [GESP202506 四级 C++] 第 21 题

[GESP202506 四级 C++] 第 21 题

以下程序中使用了递推方式计算阶乘(n!=1×2...×nn! = 1 \times 2 ... \times n),计算结果正确。

int factorial(int n) {
    int res = 1;
    for (int i = 0; i < n; ++i) {
        res *= i;
    }
    return res;
}

{{ select(1) }}

  • 正确
  • 错误