用C语言求s=1+1/1!+1/2!+1/3!+...+1/10!。
时间: 2023-11-17 21:00:24 浏览: 86
C#求1-1/2+1/3-1/4+…….-1/100的值
```c
#include <stdio.h>
int main() {
int i, j;
double sum = 1, fac = 1;
for (i = 1; i <= 10; i++) {
fac *= i;
sum += 1.0 / fac;
}
printf("s=1+1/1!+1/2!+1/3!+...+1/10!=%f\n", sum);
return 0;
}
```
阅读全文