题解 | #n的阶乘#
n的阶乘
https://www.nowcoder.com/practice/97be22ee50b14cccad2787998ca628c8
#include<bits/stdc++.h> using namespace std; long jiecheng(int n) {//返回值需要为long,否则13之后的数会因为结果过大而溢出 if (n == 0 || n == 1) { return 1; } else { return n * jiecheng(n - 1); } } int main() { int n; cin >> n; long result = jiecheng(n); cout << result; }