#include<stdio.h>
int main()
{
int i, N, S, sum;//定义i用来限制循环次数
S = 1;sum = 0;
scanf("%d", &N);
for (i = 1;i <= N;i++)
{
S = S * i;//S为阶乘
sum = sum + S;
}
printf("%d", sum);
return 0;
}
04-22
496
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)