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])
1 ответ
+ 3
Program for Fibonacci numbers
https://www.geeksforgeeks.org/program-for-nth-fibonacci-number
Good Luck