c语言求s=1!+2!+3!+…+10!的结果
时间: 2023-12-31 09:03:19 浏览: 239
求数字阶乘之和(1!+2!+3!+...+10!)
以下是C语言求s=1!+2!+3!+…+10!的结果的代码:
```c
#include <stdio.h>
int main() {
int n = 10;
int sum = 0;
int factorial = 1;
for (int i = 1; i <= n; i++) {
factorial *= i;
sum += factorial;
}
printf("s = %d", sum); // 输出:s = 4037913
return 0;
}
```
阅读全文