Fibonacci
Denis TRYSTRAM
Lecture notes Maths for Computer Science – MOSIG 1 – 2015
1
Fibonacci numbers
In the original problem introduced by Leonardo of Pisa (Fibonacci) in the
middle age, this number is the number of pairs of rabbits that can be produced at the n-th generation. Starting by a single pair of rabbits and assuming that each pair produces a new pair of rabbits at each generation during
only two generations.
Definition. Given the two numbers F(0) = 1 and F(1) = 1, the Fibonacci
numbers are obtained by the following expression: F(n+1) = F(n)+F(n-1).
!"
!"
#"
$"
%"
Figure 1: Construction of the Fibonacci progression
Notice that it is a special case of un+1 = α.un + β.un−1 for a = b = 1.
2
Some recurrences on Fibonacci numbers
These numbers have nice properties, like the following ones.
2.1
A first property: computing the product of two consecutive Fibonacci numbers
F (n − 1).F (n) =
Pn−1
k=0
F 2 (k) (for n ≥ 1)
• The relation can be proved by using a geometric argument (see figure
2).
!"&$%
!"'$%
!"#$%
Figure 2: Geometric interpretation of the relation F (4).F (5) = F 2 (0) +
F 2 (1) + F 2 (2) + F 2 (3) + F 2 (4).
• Proof by induction.
The basis case is to check F (0).F (1) = F 2 (0), which is true.
Induction step: Let assume this property holds for rank n and compute F (n + 1).F (n).
According to the definition of F (n + 1), we have
F (n + 1).F (n) = (F (n) + F (n − 1)).F (n) = F 2 (n) + F (n − 1).F (n)
We apply now the induction hypothesis to this last term:
P
Pn−1 2
F (k) = nk=0 F 2 (k).
F (n + 1).F (n) = F 2 (n) + k=0
2.2
Another property dealing with squares
We will show the following property by three different methods
F (n + 1)2 = 4.F (n).F (n − 1) + F (n − 2)2 for n ≥ 2.
• The geometrical proof is simply obtained by using Fubini’s principle
as depicted in Figure 3.
F(n+1)!
F2(n-2)!
F(n-1)!
F(n)!
Figure 3: Geometric interpretation for computing F (n + 1)2 .
2
• Another proof uses directly the definition of F (n + 1):
F 2 (n + 1) = F 2 (n) + 2.F (n).F (n − 1) + F 2 (n − 1)
Again, using the definition of F (n) and developing the square, we get:
F 2 (n+1) = F 2 (n−2)+2.F (n−1).F (n−2)+2.F (n).F (n−1)+2F 2 (n−1)
= F 2 (n − 2) + 2.F (n).F (n − 1) + 2.F (n − 1)(F (n − 2) + F (n − 1))
We obtain the result by applying a third time the definition F (n − 2) +
F (n − 1) = F (n).
• This result is much more difficult to derive by induction since there is
no obvious structural properties that link two successive squares.
2.3
Cassini’s identity
Show the following Cassini’s identity: F (n − 1).F (n + 1) = F 2 (n) + (−1)n+1
for n ≥ 1.
• The proof by induction is as follows:
The basis case is straightforward since F (0).F (2) = 2 and F 2 (1)+1 =
2.
Below is the detail of the induction step, assuming the Cassini’s
identity holds at rank n.
F (n).F (n + 2) = F (n)(F (n + 1) + F (n)) by definition of the Fibonacci
progression
= F (n).F (n + 1) + F (n)2
from the recurrence hypothesis, we have
F 2 (n) = F (n − 1).F (n + 1) − (−1)n+1 = F (n − 1).F (n + 1) + (−1)n+2
Thus,
F (n).F (n + 2) = F (n).F (n + 1) + F (n − 1).F (n + 1) + (−1)n+2
= F (n + 1)(F (n) + F (n − 1)) + (−1)n+2 and again, since F (n) + F (n −
1) = F (n + 1)
= F 2 (n + 1) + (−1)n+2
• The previous result (Cassini’s identity) is the basis of a geometrical
paradox (one of the favorite puzzle of Lewis Carroll). Consider a chess
board and cut it into 4 pieces as shown in figure 2.3, then reassemble
them into a rectangle.
The surface of the square is F (n)2 while the rectangle is F (n+1).F (n−
1). The Cassini identity is applied for n = 5, F (5) = 8. From one
side, we obtain a surface of 8 × 8 = 64 and 13 × 5 = 65 from the
other side! The paradox comes from the wrong representation of the
3
diagonal of the rectangle which does not coincide with the hypothenus
of the rectangle triangles of sides F (n − 1) and F (n − 2). In other
words, it always remains (for any n) an empty space (corresponding
to the unit size of the basic case of the chess board). The greater n,
the better the paradox because the surface of this basic case becomes
more tiny.
2.4
Using Fibonacci numbers
F (n) is the number of paths from node 1 to n in the following family of
graphs of figure 4.
!"
#"
$"
%"
&"
'"
("
Figure 4: Counting paths from node 1 to node n (n = 7)
4
3
Fibonacci system number
Let us study the way the Fibonacci numbers can be used for representing
integers.
Let us first introduce a notation: j k iff j ≥ k + 2.
We will first prove the Zeckendorf ’s theorem which states that every
positive integer n has a unique representation of the form:
n = Fk1 + Fk2 + ... + Fkr where k1 k2 ... kr and kr ≥ 2.
Here, we assume that the Fibonacci progression starts at F1 = F2 = 1.
For instance, the representation of 12345 turns out to be:
12345 = 10946 + 987 + 377 + 34 + 1 = F21 + F16 + F14 + F9 + F2
Figure 5 shows the decomposition for the first integers written in this
system.
F7
F2 F4
F6
F3 F5
F8
Figure 5: The first integers (on the X-axis) broken down into the Zeckendorf
representation.
The principle is depicted in Figure 6.
• The existence can be shown by an induction on n. The proof is constructive using the following greedy rule:
Choose Fk1 as the largest Fibonacci number lower or equal to n, then,
choose Fk2 as the largest one that is less than n − Fk1 and so on...
Figure 7 shows how to obtain a Fibonacci number n from its ancestor
n − 1.
5
Figure 6: Principle of the construction.
• The uniqueness of this representation is proved by contradiction.
Assume there are two different such representations.
Any unique system of representation is a numbering system.
The previous theorem ensures that any non-negative integer can be written as a sequence of bits bi , in other words,
n = (bm bm−1 ...b2 )F iff n = Σm
k=2 bk Fk .
• Write the Fibonacci representation of 12345 and compare it to the
usual binary representation.
12345 = (100001010000100000010)F .
Recall that 12345 = 213 + 212 + 25 + 24 + 23 + 20 = (1100000111001)2 .
• The binary representation is more compact.
The decomposition in the Fibonacci basis of the first 8 integers (starting from 1 = (00001)F ) is as follows:
2 = (00010)F
3 = (00100)F
4 = 3 + 1 = (00101)F
5 = (01000)F
6 = 5 + 1 = (01001)F
7 = 5 + 2 = (01010)F
8 = (10000)F
6
Figure 7: Jumping to the next Fibonacci number.
• We can prove that there is no consecutive digits equal to 1 in such
representations.
This is easy by contradiction. If there exists a number N with such
a representation, we consider the two first ranks where a double 1
appear, say k + 1 and k, this means that N contains F (k + 1) + F (k)
as a sub-sum. As F (k + 1) + F (k) = F (k + 2), this is not a valid
decomposition.
Let us now study how to perform basic arithmetic operations within this
system.
We will focus on the increment (addition of 1): obtaining n + 1 from n.
• Detail first this operation when the last digit is 0 and justify it.
• Give a process to obtain the increment of n when its two last digits
are 01.
7
© Copyright 2026 Paperzz