Back to exercises

Fibonacci

Track only the previous two numbers and iterate until you reach n. This keeps the solution clear and avoids exponential recursion.

Coding Exercises Easy O(n)

Fibonacci

Track only the previous two numbers and iterate until you reach n. This keeps the solution clear and avoids exponential recursion.

Return the nth Fibonacci number.