int main() // 1的阶乘+2的阶乘+3的阶乘.......
{
int i = 0;
int n = 0;
int ret = 0;
int sum = 0;
int c = 0;
scanf("%d", &n);
for (c = 1; c <= n; c++)
{
ret = 1;
for (i = 1; i <= c; i++) //循环ret里面是每次阶乘的值
{
ret = ret*i; //注意ret 在第二次进入循环的值
}
sum += ret;
}
printf("sum = %d\n", sum);
return 0;
}
03-11
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-03
3316
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-12
5171
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-22
3564
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)