Your question is Compute Nth Fibonacci Number. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
On a Glassdoor engineering screen, you may be asked to implement a basic sequence generator efficiently. Write a function that returns the nth Fibonacci number.
The Fibonacci sequence is defined as:
F(0) = 0F(1) = 1F(n) = F(n - 1) + F(n - 2) for n >= 2nF(n)Your solution should handle the base cases correctly and avoid the exponential slowdown of naive recursion.
n is an integerdef fibonacci(n):