- 1

how to find fibonacci series using recursion

18th Nov 2017, 3:46 PM
shalini
shalini - avatar
3 Réponses
+ 5
num = int(input()) #Entrada del usuario def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return fibonacci(n-1) + fibonacci(n-2) for i in range(num): print(fibonacci(i)) #Llamada de la funcion
12th Oct 2020, 12:02 PM
Kevin Rojas
Kevin Rojas - avatar
0
num = int(input()) fib = [0, 1] def fibonacci(n): if n == 2: [print(i) for i in fib] else: fib.append(sum(fib[-2:])) fibonacci(n - 1) fibonacci(num)
2nd Jul 2022, 1:59 PM
Avraham Baron