c语言的方法求s = 1!+2!+3!+4!+...+20! 结果: 2561327494111820300.000000
时间: 2023-11-24 15:07:22 浏览: 103
以下是C语言的代码,用于计算1!+2!+3!+4!+...+20!的结果:
```c
#include <stdio.h>
int main() {
double sum = 0;
double factorial = 1;
for (int i = 1; i <= 20; i++) {
factorial *= i;
sum += factorial;
}
printf("s = %lf\n", sum);
return 0;
}
```
输出结果为:s = 2561327494111820300.000000
阅读全文