Fibonacci (Recursion)

Print the nth Fibonacci number, where fib(0) = 0 and fib(1) = 1. Plain recursion is too slow for big n: remember results or loop.

Input: One integer 0 ≤ n ≤ 90.

Output: fib(n).

Difficulty: Medium. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Memoisation, or keep the last two values in a loop.

More Recursion practice