1.

Write a python function generatefibo(n) where n is the limit, using a generator function Fibonacci (max)(where max is the limit n) that produces Fibonacci series.

Answer»

def Fibonacci (max):

a, b = 0, 1

while a <= max:

yield a

a, b = b, a + b

def generatefibo(n)

for i in Fibonacci (n):

print i,



Discussion

No Comment Found

Related InterviewSolutions