You are viewing a single comment's thread. Return to all comments →
python3 using a generator
def fib(): a, b = 0, 1 while True: yield a a, b = b, a+b
def isFibo(n): # Write your code here f = fib() a = next(f) while a < n: a = next(f) if a == n: return 'IsFibo' else: return 'IsNotFibo'
Seems like cookies are disabled on this browser, please enable them to open this website
Is Fibo
You are viewing a single comment's thread. Return to all comments →
python3 using a generator
def fib(): a, b = 0, 1 while True: yield a a, b = b, a+b
def isFibo(n): # Write your code here f = fib() a = next(f) while a < n: a = next(f) if a == n: return 'IsFibo' else: return 'IsNotFibo'