Fibonacci number

In mathematics, the Fibonacci numbers form a sequence in which the first number is 0, the second number is 1, and each subsequent number is equal to the sum of the previous two numbers in the series. In mathematical terms, it is defined by the following recurrence relation:

F_n := \begin{cases} 0            & \mbox{if } n = 0; \\ 1            & \mbox{if } n = 1; \\ F_{n-1}+F_{n-2} & \mbox{if } n > 1. \\  \end{cases} $$

The sequence of Fibonacci numbers starts with : 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, ...

It was first used to represent the growth of a colony of rabbits, starting with a single pair of rabbits. It has applications in mathematics as well as other sciences, and is a popular illustration of recursive programming in computer science.

Divisibility properties
We will apply the following simple observation to Fibonacci numbers:

if three integers $$\ a,b,c,$$ satisfy equality $$\ c = a+b,$$  then
 * $$\ \gcd(a,b)\ =\ \gcd(a,c)=\gcd(b,c)$$

where "gcd" denotes the greatest common divisor.


 * $$\gcd\left(F_n,F_{n+1}\right)\ =\ \gcd\left(F_n,F_{n+2}\right)\ =\ 1$$

Indeed,


 * $$\gcd\left(F_0,F_1\right)\ =\ \gcd\left(F_0,F_2\right)\ =\ 1$$

and the rest is an easy induction.


 * $$F_n\ =\ F_{k+1}\cdot F_{n-k} + F_k\cdot F_{n-k-1}$$


 * for all integers $$\ k,n,$$ such that $$\ 0\le k < n.$$

Indeed, the equality holds for $$\ k=0,$$ and the rest is a routine induction on $$\ k.$$

Next, since $$\gcd\left(F_k,F_{k+1}\right) = 1$$, the above equality implies:


 * $$\gcd\left(F_k,F_n\right)\ =\ \gcd\left(F_k,F_{n-k}\right)$$

which, via Euclid algorithm, leads to:


 * $$\gcd(F_m, F_n)\ =\ F_{\gcd(m,n)} $$

Let's note the two instant corollaries of the above statement:


 * If $$\ m$$ divides $$\ n\ $$ then $$\ F_m\ $$ divides $$\ F_n\ $$


 * If $$\ F_p\ $$ is a prime number different from 3, then $$\ p$$  is prime. (The converse is false.)

Algebraic identities

 * $$F_{n-1}\cdot F_{n+1}-F_n\,^2\ =\ (-1)^n\ $$    for n=1,2,...
 * $$\sum_{i=0}^n F_i\,^2\ =\ F_n \cdot F_{n+1}$$

Direct formula and the golden ratio
We have
 * $$F_n\ =\ \frac{1}{\sqrt{5}}\cdot \left(\left(\frac{1+\sqrt{5}}{2}\right)^n - \left(\frac{1-\sqrt{5}}{2}\right)^n\right)$$

for every $$\ n=0,1,\dots$$.

Indeed, let $$A := \frac{1+\sqrt{5}}{2}$$  and  $$a := \frac{1-\sqrt{5}}{2}$$. Let


 * $$f_n\ :=\ \frac{1}{\sqrt{5}}\cdot(A^n - a^n)$$

Then:
 * $$f_0 = 0\ $$    and     $$\ f_1 = 1$$
 * $$A^2 = A+1\ $$    hence     $$\ A^{n+2} = A^{n+1}+A^n$$
 * $$a^2 = a+1\ $$    hence     $$a^{n+2} = a^{n+1}+a^n\ $$
 * $$f_{n+2}\ =\ f_{n+1}+f_n$$

for every $$\ n=0,1,\dots$$. Thus $$\ f_n = F_n$$ for every $$\ n=0,1,\dots,$$ and the formula is proved.

Furthermore, we have:


 * $$A\cdot a = -1\ $$
 * $$A > 1\ $$
 * $$-1 < a < 0\ $$
 * $$\frac{1}{2}\ >\ \left|\frac{1}{\sqrt{5}}\cdot a^n\right|\quad\rightarrow\quad 0$$

It follows that
 * $$F_n\ $$ is the nearest integer to  $$\frac{1}{\sqrt{5}}\cdot \left(\frac{1+\sqrt{5}}{2}\right)^n$$

for every $$\ n=0,1,\dots$$. The above constant $$\ A$$ is known as the famous golden ratio $$\ \Phi.$$  Thus:


 * $$\Phi\ =\ \lim_{n\to\infty}\frac{F_{n+1}}{F_n}\ =\ \frac{1+\sqrt{5}}{2}$$

Fibonacci generating function
The Fibonacci generating function is defined as the sum of the following power series:


 * $$g(x)\ :=\ \sum_{n=0}^\infty F_n\cdot x^n$$

The series is convergent for $$\ |x|<\frac{1}{\Phi}.$$  Obviously:


 * $$g(x)\ =\ x+x\cdot g(x) + x^2\cdot g(x)\ $$

hence:


 * $$g(x)\ =\ \frac{x}{1-x-x^2}$$

Value $$\ g(x)$$ is a rational number whenever x is rational. For instance, for x = &frac12;:


 * $$\frac{F_1}{2}+\frac{F_2}{4}+\frac{F_3}{8}+\cdots\ =\ 2$$

and for x = &minus;&frac12; (after multiplying the equality by &minus;1):


 * $$\frac{F_1}{2}-\frac{F_2}{4}+\frac{F_3}{8}-\cdots\ =\ \frac{2}{5}$$