Challenge: Fibonacci Number

Solve the Fibonacci Number Problem.

We'll cover the following...

Problem


Fibonacci Number Problem

Compute the nn-th Fibonacci number.

Input: An integer nn.

Output: The nn-th Fibonacci number.

Press + to interact
Formula of Fibonacci number
Formula of Fibonacci number

Fibonacci numbers are defined recursively:

Fn={nifnis0or1Fn2+Fn1ifn2F_n = \begin{cases}n & \mathrm{if}\:n\:\mathrm{is}\:0\:\mathrm{or}\:1 \\F_{n-2} + F_{n-1} & \mathrm{if}\:n\geq2\end{cases} ...