fastest python fibonacci recursive code example
Example: fibonacci recursive python
#fibonacci sequence with memory to increase the speed.
class recur_fibo:
memory = {0: 1, 1:1}
def fibonacci(n):
if n in recur_fibo.memory:
return recur_fibo.memory[n]
else:
recur_fibo.memory[n] = recur_fibo.fibonacci(n-1) + recur_fibo.fibonacci(n-2)
return recur_fibo.memory[n]
if __name__ == "__main__":
value = recur_fibo.fibonacci(200)
print(value)