题解 | #n的阶乘#
n的阶乘
http://www.nowcoder.com/practice/97be22ee50b14cccad2787998ca628c8
用递推比递归更加快
#include <iostream>
using namespace std;
typedef long long LL;
LL fact[25];
int main()
{
int n;
cin >> n;
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = i * fact[i-1];
cout << fact[n] << endl;
}