求∑_(n=1)^(100)n+∑_(k=1)^(50)k^2+∑_(k=1)^(10)1/k ___(用C语言while)
时间: 2023-12-11 16:06:11 浏览: 73
迭代序列xn+1=(α+βxn-k)/(1+k∑i=1xy n-i+1)的全局性质 (2008年)
以下是用 C 语言 while 循环实现的代码:
```c
#include <stdio.h>
int main() {
int n = 1, k = 1;
int sum1 = 0, sum2 = 0, sum3 = 0;
while (n <= 100) {
sum1 += n;
n++;
}
while (k <= 50) {
sum2 += k * k;
k++;
}
while (k <= 10) {
sum3 += 1.0 / k;
k++;
}
printf("∑(n=1)^(100)n + ∑(k=1)^(50)k^2 + ∑(k=1)^(10)1/k = %d + %d + %d\n", sum1, sum2, sum3);
return 0;
}
```
输出结果为:
```
∑(n=1)^(100)n + ∑(k=1)^(50)k^2 + ∑(k=1)^(10)1/k = 5050 + 42925 + 0
```
阅读全文