Image from Pixabay
The Fibonacci sequence was first observed by the Italian mathematician Leonardo Fibonacci in 1202. He was investigating how fast rabbits could breed under ideal circumstances. He made the following assumptions:
Fibonacci asked how many pairs of rabbits would be produced in one year.
Can you create the numbers yourself? Remember to count the 'pairs' of rabbits and not the individual ones. Try it.
Were you able to come up with the Fibonacci numbers? If not, here is how you would do it.
The pattern comes out to be 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233.
Fibonacci numbers are of interest to biologists and physicists because they are frequently observed in various natural objects and phenomena. For example, the branching patterns in trees and leaves are based on Fibonacci numbers.
On many plants, the number of petals is a Fibonacci number: buttercups have 5 petals; lilies and iris have 3 petals; some delphiniums have 8; corn marigolds have 13 petals; some asters have 21 whereas daisies can be found with 34, 55 or even 89 petals.
How can we create a rule (algorithm) for the fibonacci series (sequence)?
First, the terms are numbered from 0 onwards like this:
n = 0 1 2 3 4 5 6 7 8 9 10 ...
xn =0 1 1 2 3 5 8 13 21 34 55 ...
What rule can we create here? Well, if you look, x3 = x2 + x 1 (2 = 1 + 1) and x4 = x2 + x3 (3 = 1 + 2), etc.
So we can write the rule (algorithm) as: xn = x(n-1) + x(n-2).
Example: term 7 is calculated as:
x7= x(7-1) + x(7-2)
= x6 + x5
= 13 + 8
Let's write programs in Python to calculate the Fibonacci numbers.
1. With looping:
a,b = 1,1
for i in range(n-1):
a,b = b,a+b
1. With recursion:
if n==1 or n==2:
N.B: No not copy and paste the python code as identation is important.
Write something about yourself. No need to be fancy, just an overview.