python 有一分数序列:2/1, 3/2,5/3, 8/5,13/8 ,21/13...求出返个数列的前20項之和
时间: 2023-10-29 20:04:40 浏览: 72
python 有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和 (示例)
5星 · 资源好评率100%
Sure, the sum of the first 20 terms of the given sequence is 32.66026079864264. You can find the code to calculate the sum as follows:
```python
a, b = 2, 1
total = 0
for i in range(20):
total += a / b
a, b = a + b, a
print(total)
```
阅读全文