c语言求1!+2!+3! +4! +5! +6! +7! +8! +9! +10! 的值
时间: 2023-12-01 08:43:13 浏览: 126
GTK+ 2.0 教程
以下是C语言求1!+2!+3! +4! +5! +6! +7! +8! +9! +10! 的值的代码:
```c
#include <stdio.h>
int main() {
int i, j, sum = 0, factorial = 1;
for (i = 1; i <= 10; i++) {
factorial = 1;
for (j = 1; j <= i; j++) {
factorial *= j;
}
sum += factorial;
}
printf("1!+2!+3!+...+10! = %d", sum); // 输出:1!+2!+3!+...+10! = 4037913
return 0;
}
```
阅读全文