dsa · easy

Nth Fibonacci Number

GreyOrangeMathRecursionDynamic ProgrammingFoundation

Return the n-th Fibonacci number. F(0)=0, F(1)=1, F(n)=F(n-1)+F(n-2).

Arguments

**Example:** n = 68.

Constraints

0 <= n <= 30 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
2

Expected:
1

Example 2

Input:
6

Expected:
8

Open in the Dojo editor