int factorial(int n)
{
int i, result;
for(i = ; i <= n; i++)
result *= i;
return result;
} int factorial2(int n)
{
if(n <= )
return ;
else
return n * factorial2(n-);
}
以下列出0至20的阶乘:
0!=1,注意(0的阶乘是存在的)
1!=1,
2!=2,
3!=6,
4!=24,
5!=120,
6!=720,
7!=5,040,
8!=40,320
9!=362,880
10!=3,628,800
11!=39,916,800
12!=479,001,600
13!=6,227,020,800
14!=87,178,291,200
15!=1,307,674,368,000
16!=20,922,789,888,000
17!=355,687,428,096,000
18!=6,402,373,705,728,000
19!=121,645,100,408,832,000
20!=2,432,902,008,176,640,000
另外,定义,0!=1,所以0!=1!
而当n≥5时,n!的个位数字都是0.