编程计算下面表达式前20项的和:1/(1*2)+1/(2*3)+1/(3*4)+⋯+1/(n*(n+1)) 输入格式:无 输出格式:"s=%.3f\n"
时间: 2023-11-06 19:08:04 浏览: 299
```
#include <stdio.h>
int main() {
double sum = 0;
for (int i = 1; i <= 20; i++) {
sum += 1.0 / (i * (i + 1));
}
printf("s=%.3f\n", sum);
return 0;
}
```
阅读全文