Programming Fibonacci

randerson112358
4 min readJan 7, 2018

The Fibonacci sequence is named after the Italian mathematician Leonardo of Pisa also known as Fibonacci. Although the sequence was described earlier in Indian mathematics, he introduced it to the Western European mathematics. By definition the first two numbers of the infinite sequence is either 0 and 1 or 1 and 1, and every other preceding number is the sum of the two previous numbers.

Fibonacci Sequence: 1,1,2,3,5,8,13,21,….
Modern Fibonacci Sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21,…

The Fibonacci Sequence is defined by the following recurrence relation:

Fib(0) = 0
Fib(1) = 1
Fib(n) = Fib(n-1) + Fib(n-2)

Don’t be over whelmed by the recurrence relation above. Fib(n) is just a function similar to f(x), Fib is short for Fibonacci. Fib(0) is a Fibonacci function with input 0, and outputs the value 0, and is considered one of the base cases because it returns a specific constant. Fib(1) is a Fibonacci function with input 1, and it outputs the value 1, it is another base case of the Fibonacci function. Now for the tricky part Fib(n) is the recursive case of the Fibonacci function with some arbitrary input ’n’ it is equal to Fib(n-1) + Fib(n-2). Recursive just means it’s a function that calls itself or is defined by itself. So if for example n = 2, then…

--

--

No responses yet