Fibonacci

Non recursive approach

Equation

$$ f_{n} = \begin{cases} 0 & \text{if } n = 0 \\ 1 & \text{if } n = 1 \\ f_{n-1}+f_{n-2} & \text{if } n >=2 \end{cases} $$

Manualy calculated examples

n f0 f1 fn
0 0 0 0
1 0 1 1
2 0 1 1
3 1 1 2
4 1 2 3
5 2 3 5
6 3 5 8
7 5 8 13
8 8 3 21
9 13 21 34
10 21 34 55
11 34 55 89
12 55 89 144
13 89 144 233
14 144 233 377
15 233 377 610
16 377 610 987
17 610 987 1597
18 987 1597 2584
19 1597 2584 4181
20 2584 4181 6765

GitHub

View Github