python3 yield實現斐波那契數列

def fab(max): n,a,b = 0,0,1 while n < max: yield a+b a,b = b,a+b n += 1 for i in fab(5): print(i)
相關文章
相關標籤/搜索