?计算1!+2!+3!+4!+5!+6!+7!+8!+9!+10!
代码示例:
#include <stdio.h>
int main()
{
int i = 0;
int n = 0;
int ret = 1;
int sum = 0;
for (n = 1; n <= 10; n++)
{
ret = 1;
for (i = 1; i <= n; i++)
{
ret = ret * i;
}
sum = sum + ret;
}
printf("%d\n", sum);
return 0;
}
运行结果:
4037913