Serie Fibonacci utilizando un enfoque de programación dinámica
def fib(n, solved):
# Base case
if n == 0 or n == 1 :
solved[n] = n
# If the value is not calculated yet then calculate it
if solved[n] is None:
solved[n] = fib(n-1, solved)+fib(n-2, solved)
# return the value from table for n
return solved[n]
n = 12
solved = [None]*(n+1)
fib(n, solved)
for i, num in enumerate(solved):
print(i, num)
Bloody Bat