python实现斐波那契数列

通过生成器方式

def fib_loop_while(max):
    a, b = 0, 1
    while max > 0:
        a, b = b, a + b
        max -= 1
        yield a


for i in fib_loop_while(10):
    print(i)

 

posted on 2020-04-19 16:04  芦荟~lh  阅读(150)  评论(0编辑  收藏  举报

导航