Fibonacci Number

Given n, return the n-th Fibonacci number. Pattern focus: Linear Recurrence DP. This is the simplest example of a state that depends on a fixed number of previous states.

Input Format

n = Fibonacci index

Output Format

the n-th Fibonacci number

Constraints

  • 0 <= n <= 45

Examples

Example 1:

Input:

n = 0

Output:

0

Explanation:

F(0) is 0.

Example 2:

Input:

n = 7

Output:

13

Explanation:

The sequence is 0,1,1,2,3,5,8,13.

Loading...
Fibonacci Number - Dp 1d DSA Problem