Problems

Fibonacci Number

easy
easy
math
dynamic-programming

The Fibonacci numbers form a sequence such that each number is the sum of the two preceding ones, starting from 0 and 1.

F(0) = 0, F(1) = 1, and F(n) = F(n - 1) + F(n - 2) for n > 1.

Given n, return F(n).

Examples

Example 1

Input: n = 2
Output: 1

Example 2

Input: n = 5
Output: 5

Example 3

Input: n = 10
Output: 55

Running will execute all 3 cases.