Skip to content
Advertisement

Nth Fibonacci in python

JavaScript

I’m a Java programmer learning python. This algorithm computes the nth fibonacci number using recursion + memoization. I don’t understand why I’m seeing this error “IndexError: list index out of range” when running the program in python. Can anybody help? Thanks a ton!

Advertisement

Answer

I made few changes in your code to get nth Fibonacci no.(there might be other way too)

JavaScript

And output is :-

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement