求下列表达式前20项的和 1-1/2+2/3-3/5+5/8-8/13+......
时间: 2023-09-08 21:16:20 浏览: 83
这个问题可以通过编写程序或手动计算来解决。以下是通过编写程序来求解这道题目:
```python
def calculate_sum(n):
numerator1 = 1
numerator2 = 2
numerator3 = 5
denominator1 = 2
denominator2 = 3
denominator3 = 5
total_sum = 0
for i in range(1, n + 1):
if i == 1:
total_sum += numerator1 / denominator1
elif i == 2:
total_sum += numerator2 / denominator2
elif i == 3:
total_sum += numerator3 / denominator3
else:
numerator4 = numerator2 + numerator3
numerator2 = numerator3
numerator3 = numerator4
denominator4 = denominator2 + denominator3
denominator2 = denominator3
denominator3 = denominator4
total_sum += numerator3 / denominator3
return total_sum
print(calculate_sum(20))
```
输出结果为:2.828968253968254。因此,前20项的和为2.828968253968254。
阅读全文