c语言s=1/2*1/(2*2*2)*1/(2*n*n)..
时间: 2023-12-06 18:04:17 浏览: 78
根据您提供的引用内容,我了解到您想要计算类似于s=1/2*1/(2*2*2)*1/(2*n*n)的级数和。下面是一个C语言的实现例子:
```c
#include <stdio.h>
#include <windows.h>
double fun(int n) {
if (n < 0) return 0.0;
double s = 0.0;
int i;
for (i = 1; i <= n; i++) s = s + 1.0 / (i * (i + 1));
return s;
}
int main() {
int t = 10;
double result = fun(t);
printf("result is %f \n", result);
system("pause");
return 0;
}
```
运行结果为:
```
result is 0.909091
```
阅读全文