python程序,输出前20个斐波那契数列,每行输出5个数
时间: 2023-05-21 18:01:57 浏览: 99
python 输出斐波那契数列的前20个数 示例
5星 · 资源好评率100%
Sure, here's the code to output the first 20 Fibonacci numbers in Python:
```
a, b = 0, 1
for i in range(20):
print(b, end=' ')
a, b = b, a + b
if (i+1) % 5 == 0:
print()
```
This will output the first 20 Fibonacci numbers, with 5 numbers per line.
阅读全文