python脚本9_打印斐波那契数列

#打印斐波那契数列

f0 = 0
f1 = 1
for n in range(2,101):
    fn = f1 + f0
    if fn <= 100:   
        print(fn)
        f0 = f1
        f1 = fn

 方法2:

#打印斐波那契数列,100以内

print(0)
print(1)
a = 0
b = 1
while True:
    c = a+b
    if c > 100: 
    break a = b b = c print(c)

 

posted @ 2019-01-01 14:51  真坤  阅读(641)  评论(0编辑  收藏  举报