fibonacci recursion iterative fibonacci

Fibonacci Numbers


A mathematical model of nature's spirals

by Robert Deveau 2013


Return to Practical Recursion Home




Your browser does not support this page.
phi.png
If line A is divided into 2 segments, and the ratio of length A to length B is equal to the ratio between B to C, it will be Phi, the Golden ratio 1.618...
For more information on Phi visit the Golden Number

Generating the Nth Fibonacci number (recursive, iterative or formula?)

A recursive fibonnacci function

To get the Nth Fibonacci number, we will need to obtain the previous 2, and then, the next previous 2 until we get to our base cases 0 and 1.


An Iterative fibonnacci function

* the shift() removes the first item in the array and returns that item; the length of the array also gets reduced by one


The easiest way is to use our GOLDEN NUMBER 1.618

Fn = 1.618n/ 5.5 especially when you want the larger numbers like 40. * we can use our recursive exponent function here.

Next up is The Towers of Hanoi or Return to home page.

©2013 deveau enterprises