代码:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int n;
scanf_s("%d", &n);
int temp = 1, sum = 0;
for (int i = 1; i <= n; ++i)
{
temp *= i; //迭代计算每个的阶乘
sum += temp;
}
printf("%d\n", sum);
return 0;
}
代码:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int n;
scanf_s("%d", &n);
int temp = 1, sum = 0;
for (int i = 1; i <= n; ++i)
{
temp *= i; //迭代计算每个的阶乘
sum += temp;
}
printf("%d\n", sum);
return 0;
}