Fibonacci Number - II

You are given a non-negative integer N. Find the Nth Fibonacci number.

The Fibonacci sequence is defined as:

  • F(0) = 0
  • F(1) = 1
  • F(N) = F(N - 1) + F(N - 2) for N > 1

Example 1:

Input:

1

Output:

1

Explanation:

F(1) = 1.

Example 2:

Input:

10

Output:

55

Explanation:

The tenth Fibonacci number F(10) is 55.

Now Your Turn!

Pick the correct output for the given input

Input:

N = 5

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 <= 15

Hints

0
class Solution {
public:
int fibonacci(int N) {
// Write your logic here
}
};
Test Case

Input:

N