0

Is there better way to write Fibonacci project? I feel like I am cheating.

num = int(input()) ls = [0, 1, 1] def fib(n): #complete the recursive function if n <= 1: return 0 elif n == 2: return 1 else: a = fib(n-1) b = fib(n-2) x = a + b if x > ls[-1]: ls.append(x) return x fib(num) for i in range(num): print(ls[i])

7th Dec 2021, 11:54 AM
Hein Thant
Hein Thant - avatar
1 Réponse
+ 3
7th Dec 2021, 12:07 PM
SoloProg
SoloProg - avatar