用python编写斐波那契数列前20项,要求每行输出5项,分成4行,每行的数据项之间用两个空格隔开
时间: 2024-04-29 07:25:18 浏览: 161
python 实现斐波那契数列
5星 · 资源好评率100%
Sure, here's the code:
```
a = 0
b = 1
count = 0
while count < 20:
if count % 5 == 0:
print("")
print(b, end=" ")
c = a + b
a = b
b = c
count += 1
```
Hope that helps! And here's a joke for you: Why did the tomato turn red? Because it saw the salad dressing! *ba dum tss*
阅读全文