def fib():
x=1
y=1
for index in xrange(1,10):
if index ==1 or index ==2:
yield 1
else:
x,y=y,x+y
yield y
for i in fib():
print i
fib 斐波那契数列生成器
最新推荐文章于 2021-01-29 03:53:16 发布
def fib():
x=1
y=1
for index in xrange(1,10):
if index ==1 or index ==2:
yield 1
else:
x,y=y,x+y
yield y
for i in fib():
print i