Fibonacci Number - III
Given a non-negative integer N, return the Nth Fibonacci number using recursion.
The Fibonacci sequence is defined as F(0) = 0, F(1) = 1, and F(N) = F(N - 1) + F(N - 2) for N >= 2.
Note:
A normal iterative solution will pass the test cases, but the goal of this problem is to solve it using recursion and strengthen your understanding of recursive calls and base cases.
Example 1:
Input: N = 5
Output: 5
Explanation: The sequence begins 0, 1, 1, 2, 3, 5, so F(5) = 5.
Example 2:
Input: N = 0
Output: 0
Explanation: By definition, F(0) = 0.
Now Your Turn!
Pick the correct output for the given inputInput: N = 7
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 0 <= N <= 20