Introduction

This is my blog of programming, I take notes and leave codes of computer science problems I solved here. Be my guest to comment :)

Tuesday, December 4, 2012

The Fibonacci Numbers


  • The rabbits growth problem:

Fibonacci's book Liber Abaci written in 1202 concerned about the growth of the number of rabbits in a certain area. The problem is: A young pair of rabbits, one of each sex, is placed on an island. Assuming that rabbits do not breed until they are two months old and after they are two months old, each pair of rabbits produces another pair each month, how many pairs are there after n months?

Let f(n) be the number of rabbits after n months. We have f(1) = 1 because only the original pair is on the island after one month. As this pair does not breed during the second month, f(2) = 1. To find the number of pairs after n months, add the number on the island the previous month, f(n-1), to the number of newborn pairs, which equals to f(n-2), because each newborn pair comes from a pair at least two months old. This leads to the following definition.


  • Definition: 

The Fibonacci sequence is defined recursively by f(1) = 1, f(2) = 1, and f(n) = f(n-1) + f(n-2) for n>=3. The terms of this sequence are called the Fibonacci Numbers

No comments:

Post a Comment