How to solve Fibonacci Number
The Fibonacci sequence starts at 0, 1. The recurrence F(n)=F(nā1)+F(nā2) makes a simple recursive solution, but naive recursion repeats calls. Store intermediate values or iterate using two variables.
Time and space complexity
O(n) time and O(1) space for the iterative reference.
Practise and improve
Choose JavaScript, TypeScript or Python, complete the starter code, then select Run Tests. Request a hint when you need guidance, or choose View solution and confirm if you would like to study the reference implementation.