Loading practice problems…
Loading your practice workspace…
Loading code editor…
10 / 29
Sign in
Algorithms/Recursion

Fibonacci Number

easy20 min

The Fibonacci sequence starts with F(0) = 0 and F(1) = 1. Every later value is the sum of the previous two values.

Given n, return F(n) using a recursive solution.

Example 1

Inputn = 2

Output1

Example 2

Inputn = 6

Output8

Constraints

  • 0 ≤ n ≤ 30
  • Use recursion; memoization is allowed.
RecursionMemoization