Skip to content

Latest commit

 

History

History
36 lines (22 loc) · 425 Bytes

File metadata and controls

36 lines (22 loc) · 425 Bytes

Fibonacci

Problem Statement

Write a function fibonacci to compute the nth Fibonacci number.

Definition

The Fibonacci sequence is defined as follows:

[ F(0) = 0, \quad F(1) = 1 ]

For n ≥ 2:

[ F(n) = F(n-1) + F(n-2) ]

Examples

Example 1:

Input: 5
Output: 5

Example 2:

Input: 10
Output: 55

Constraints

  • 0 ≤ n ≤ 30
  • The input is a single integer.