def Fibonacci(x): for i in range(x): if i==0 or i == 1: a = 1 b = 1 yield 1 else: temp = a a += b b = temp yield a nr = 5 for c in Fibonacci(nr): print(c)