int main()
{
//计算n的阶乘 1*2*3*4*5*...*n-1*n
int i = 0;
int n = 0;
int num = 1;//不能初始值为0,因为每次乘以0都得0
printf("请输入需要计算的数字的阶乘");
scanf("%d",&n);
for (i = 1; i <= n; i++)
{
num = num*i;
}
printf("%d的阶乘是%d", n, num);
return 0;
}
04-17
1181
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-08
5500
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-21
478
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)