Definitions

# Fibonacci number

In mathematics, the Fibonacci numbers are a sequence of numbers named after Leonardo of Pisa, known as Fibonacci. Fibonacci's 1202 book Liber Abaci introduced the sequence to Western European mathematics, although the sequence had been previously described in Indian mathematics.

The first number of the sequence is 0, the second number is 1, and each subsequent number is equal to the sum of the previous two numbers of the sequence itself, yielding the sequence 0, 1, 1, 2, 3, 5, 8, etc. 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}

That is, after two starting values, each number is the sum of the two preceding numbers. The first Fibonacci numbers , also denoted as Fn, for n = 0, 1, 2, … ,20 are:

F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765

Every 3rd number of the sequence is even and more generally, every kth number of the sequence is a multiple of Fk.

The sequence extended to negative index n satisfies Fn = Fn−1 + Fn−2 for all integers n, and F−n = (−1)n+1Fn:

.., −8, 5, −3, 2, −1, 1, followed by the sequence above.

## Origins

The Fibonacci numbers first appeared, under the name mātrāmeru (mountain of cadence), in the work of the Sanskrit grammarian Pingala (Chandah-shāstra, the Art of Prosody, 450 or 200 BC). Prosody was important in ancient Indian ritual because of an emphasis on the purity of utterance. The Indian mathematician Virahanka (6th century AD) showed how the Fibonacci sequence arose in the analysis of metres with long and short syllables. Subsequently, the Jain philosopher Hemachandra (c.1150) composed a well-known text on these. A commentary on Virahanka's work by Gopāla in the 12th century also revisits the problem in some detail.

Sanskrit vowel sounds can be long (L) or short (S), and Virahanka's analysis, which came to be known as mātrā-vṛtta, wishes to compute how many metres (mātrās) of a given overall length can be composed of these syllables. If the long syllable is twice as long as the short, the solutions are:

1 mora: S (1 pattern)
2 morae: SS; L (2)
3 morae: SSS, SL; LS (3)
4 morae: SSSS, SSL, SLS; LSS, LL (5)
5 morae: SSSSS, SSSL, SSLS, SLSS, SLL; LSSS, LSL, LLS (8)
6 morae: SSSSSS, SSSSL, SSSLS, SSLSS, SLSSS, LSSSS, SSLL, SLSL, SLLS, LSSL, LSLS, LLSS, LLL (13)
7 morae: SSSSSSS, SSSSSL, SSSSLS, SSSLSS, SSLSSS, SLSSSS, LSSSSS, SSSLL, SSLSL, SLSSL, LSSSL, SSLLS, SLSLS, LSSLS, SLLSS, LSLSS, LLSSS, SLLL, LSLL, LLSL, LLLS (21)

A pattern of length n can be formed by adding S to a pattern of length n − 1, or L to a pattern of length n − 2; and the prosodicists showed that the number of patterns of length n is the sum of the two previous numbers in the sequence. Donald Knuth reviews this work in The Art of Computer Programming as equivalent formulations of the bin packing problem for items of lengths 1 and 2.

In the West, the sequence was first studied by Leonardo of Pisa, known as Fibonacci, in his Liber Abaci (1202). He considers the growth of an idealised (biologically unrealistic) rabbit population, assuming that:

• In the "zeroth" month, there is one pair of rabbits (additional pairs of rabbits = 0)
• In the first month, the first pair begets another pair (additional pairs of rabbits = 1)
• In the second month, both pairs of rabbits have another pair, and the first pair dies (additional pairs of rabbits = 1)
• In the third month, the second pair and the new two pairs have a total of three new pairs, and the older second pair dies. (additional pairs of rabbits = 2)

The laws of this are that each pair of rabbits has 2 pairs in its lifetime, and dies.

Let the population at month n be F(n). At this time, only rabbits who were alive at month n − 2 are fertile and produce offspring, so F(n − 2) pairs are added to the current population of F(n − 1). Thus the total is F(n) = F(n − 1) + F(n − 2).

## Relation to the Golden Ratio

### Closed form expression

Like every sequence defined by linear recurrence, the Fibonacci numbers have a closed-form solution. It has become known as Binet's formula, even though it was already known by Abraham de Moivre:
$Fleft\left(nright\right) = \left\{\left\{varphi^n-\left(1-varphi\right)^n\right\} over \left\{sqrt 5\right\}\right\}= over \left\{sqrt 5\right\}\right\}, ,$ where $varphi$ is the golden ratio
$varphi = frac\left\{1 + sqrt\left\{5\right\}\right\}\left\{2\right\} approx 1.61803,39887dots,$
(note, that $1-varphi=-1/varphi$, as can be seen from the defining equation below).

The Fibonacci recursion

$F\left(n+2\right)-F\left(n+1\right)-F\left(n\right)=0,$

is similar to the defining equation of the golden ratio in the form

$x^2-x-1=0,,$

which is also known as the generating polynomial of the recursion.

#### Proof by induction

Any root of the equation above satisfies $begin\left\{matrix\right\}x^2=x+1,end\left\{matrix\right\},$ and multiplying by $x^\left\{n-1\right\},$ shows:
$x^\left\{n+1\right\} = x^n + x^\left\{n-1\right\},$

By definition $varphi$ is a root of the equation, and the other root is $1-varphi=-1/varphi, .$. Therefore:

$varphi^\left\{n+1\right\} = varphi^n + varphi^\left\{n-1\right\},$

and

$\left(1-varphi\right)^\left\{n+1\right\} = \left(1-varphi\right)^n + \left(1-varphi\right)^\left\{n-1\right\}, .$

Both $varphi^\left\{n\right\}$ and $\left(1-varphi\right)^\left\{n\right\}=\left(-1/varphi\right)^\left\{n\right\}$ are geometric series (for n = 1, 2, 3, ...) that satisfy the Fibonacci recursion. The first series grows exponentially; the second exponentially tends to zero, with alternating signs. Because the Fibonacci recursion is linear, any linear combination of these two series will also satisfy the recursion. These linear combinations form a two-dimensional linear vector space; the original Fibonacci sequence can be found in this space.

Linear combinations of series $varphi^\left\{n\right\}$ and $\left(1-varphi\right)^\left\{n\right\}$, with coefficients a and b, can be defined by

$F_\left\{a,b\right\}\left(n\right) = avarphi^n+b\left(1-varphi\right)^n$ for any real $a,b, .$

All thus-defined series satisfy the Fibonacci recursion

begin\left\{align\right\}
F_{a,b}(n+1) &= avarphi^{n+1}+b(1-varphi)^{n+1} &=a(varphi^{n}+varphi^{n-1})+b((1-varphi)^{n}+(1-varphi)^{n-1}) &=a{varphi^{n}+b(1-varphi)^{n}}+a{varphi^{n-1}+b(1-varphi)^{n-1}} &=F_{a,b}(n)+F_{a,b}(n-1),. end{align} Requiring that $F_\left\{a,b\right\}\left(0\right)=0$ and $F_\left\{a,b\right\}\left(1\right)=1$ yields $a=1/sqrt 5$ and $b=-1/sqrt 5$, resulting in the formula of Binet we started with. It has been shown that this formula satisfies the Fibonacci recursion. Furthermore, an explicit check can be made:
$F_\left\{a,b\right\}\left(0\right)=frac\left\{1\right\}\left\{sqrt 5\right\}-frac\left\{1\right\}\left\{sqrt 5\right\}=0,!$

and

$F_\left\{a,b\right\}\left(1\right)=frac\left\{varphi\right\}\left\{sqrt 5\right\}-frac\left\{\left(1-varphi\right)\right\}\left\{sqrt 5\right\}=frac\left\{-1+2varphi\right\}\left\{sqrt 5\right\}=frac\left\{-1+\left(1+sqrt 5\right)\right\}\left\{sqrt 5\right\}=1,$

establishing the base cases of the induction, proving that

$F\left(n\right)=\left\{\left\{varphi^n-\left(1-varphi\right)^n\right\} over \left\{sqrt 5\right\}\right\}$ for all $n, .$

Therefore, for any two starting values, a combination $a,b$ can be found such that the function $F_\left\{a,b\right\}\left(n\right),$ is the exact closed formula for the series.

#### Computation by rounding

Since $begin\left\{matrix\right\}|1-varphi|^n/sqrt 5 < 1/2end\left\{matrix\right\}$ for all $ngeq 0$, the number $F\left(n\right)$ is the closest integer to $varphi^n/sqrt 5, .$ Therefore it can be found by rounding, or in terms of the floor function:
$F\left(n\right)=bigglfloorfrac\left\{varphi^n\right\}\left\{sqrt 5\right\} + frac\left\{1\right\}\left\{2\right\}biggrfloor.$

### Limit of consecutive quotients

Johannes Kepler observed that the ratio of consecutive Fibonacci numbers converges. He wrote that "as 5 is to 8 so is 8 to 13, practically, and as 8 is to 13, so is 13 to 21 almost”, and concluded that the limit approaches the golden ratio $varphi$.

$lim_\left\{ntoinfty\right\}frac\left\{F\left(n+1\right)\right\}\left\{F\left(n\right)\right\}=varphi,$
This convergence does not depend on the starting values chosen, excluding 0, 0.

Proof:

It follows from the explicit formula that for any real $a ne 0, , b ne 0 ,$

begin\left\{align\right\}
lim_{ntoinfty}frac{F_{a,b}(n+1)}{F_{a,b}(n)} &= lim_{ntoinfty}frac{avarphi^{n+1}-b(1-varphi)^{n+1}}{avarphi^n-b(1-varphi)^n} &= lim_{ntoinfty}frac{avarphi-b(1-varphi)(frac{1-varphi}{varphi})^n}{a-b(frac{1-varphi}{varphi})^n}
`    &= varphi`
end{align} because $bigl|\left\{tfrac\left\{1-varphi\right\}\left\{varphi\right\}\right\}bigr| < 1$ and thus $lim_\left\{ntoinfty\right\}left\left(tfrac\left\{1-varphi\right\}\left\{varphi\right\}right\right)^n=0 .$

### Decomposition of powers of the golden ratio

Since the golden ratio satisfies the equation
$varphi^2=varphi+1,,$
this expression can be used to decompose higher powers $varphi^n$ as a linear function of lower powers, which in turn can be decomposed all the way down to a linear combination of $varphi$ and 1. The resulting recurrence relationships yield Fibonacci numbers as the linear coefficients, thus closing the loop:
$varphi^n=F\left(n\right)varphi+F\left(n-1\right).$
This expression is also true for $n , <, 1 ,$ if the Fibonacci sequence $F\left(n\right) ,$ is extended to negative integers using the Fibonacci rule $F\left(n\right) = F\left(n-1\right) + F\left(n-2\right) . ,$

## Matrix form

A 2-dimensional system of linear difference equations that describes the Fibonacci sequence is

$\left\{F_\left\{k+2\right\} choose F_\left\{k+1\right\}\right\} = begin\left\{pmatrix\right\} 1 & 1 1 & 0 end\left\{pmatrix\right\} \left\{F_\left\{k+1\right\} choose F_\left\{k\right\}\right\}$

or

$vec F_\left\{k+1\right\} = A vec F_\left\{k\right\},.$

The eigenvalues of the matrix A are $varphi,!$ and $\left(1-varphi\right),!$, and the elements of the eigenvectors of A, $\left\{varphi choose 1\right\}$ and $\left\{1 choose -varphi\right\}$, are in the ratios $varphi,!$ and $\left(1-varphi,!\right).$

This matrix has a determinant of −1, and thus it is a 2×2 unimodular matrix. This property can be understood in terms of the continued fraction representation for the golden ratio:

$varphi$
=1 + cfrac{1}{1 + cfrac{1}{1 + cfrac{1}{;;ddots,}}} ;. The Fibonacci numbers occur as the ratio of successive convergents of the continued fraction for $varphi,!$, and the matrix formed from successive convergents of any continued fraction has a determinant of +1 or −1.

The matrix representation gives the following closed expression for the Fibonacci numbers:

$begin\left\{pmatrix\right\} 1 & 1 1 & 0 end\left\{pmatrix\right\}^n =$
begin{pmatrix} F_{n+1} & F_n F_n & F_{n-1} end{pmatrix}.

Taking the determinant of both sides of this equation yields Cassini's identity

$\left(-1\right)^n = F_\left\{n+1\right\}F_\left\{n-1\right\} - F_n^2,.$

Additionally, since $A^n A^m=A^\left\{m+n\right\}$ for any square matrix $A$, the following identities can be derived:

$\left\{F_m\right\}\left\{F_n\right\} + \left\{F_\left\{m-1\right\}\right\}\left\{F_\left\{n-1\right\}\right\} = F_\left\{m+n-1\right\},,$
$F_\left\{n+1\right\}F_\left\{m\right\} + F_n F_\left\{m-1\right\} = F_\left\{m+n\right\},.$

In particular, with $m = n$,

$F_\left\{2n-1\right\} = F_n^2 + F_\left\{n-1\right\}^2,,$
$F_\left\{2n\right\} = \left(F_\left\{n-1\right\}+F_\left\{n+1\right\}\right)F_n = \left(2F_\left\{n-1\right\}+F_n\right)F_n,.$
For another way to derive the $F_\left\{2n+k\right\}$ formulas see the "EWD note" by Dijkstra.

## Recognizing Fibonacci numbers

The question may arise whether a positive integer $z$ is a Fibonacci number. Since $F\left(n\right)$ is the closest integer to $varphi^n/sqrt\left\{5\right\}$, the most straightforward, brute-force test is the identity

$Fbigg\left(bigglfloorlog_varphi\left(sqrt\left\{5\right\}z\right)+frac\left\{1\right\}\left\{2\right\}biggrfloorbigg\right)=z,$
which is true if and only if $z$ is a Fibonacci number.

Alternatively, a positive integer $z$ is a Fibonacci number if and only if one of $5z^2+4$ or $5z^2-4$ is a perfect square.

A slightly more sophisticated test uses the fact that the convergents of the continued fraction representation of $varphi$ are ratios of successive Fibonacci numbers, that is the inequality

(with coprime positive integers $p$, $q$) is true if and only if $p$ and $q$ are successive Fibonacci numbers. From this one derives the criterion that $z$ is a Fibonacci number if and only if the closed interval
$bigg\left[varphi z-frac\left\{1\right\}\left\{z\right\},varphi z+frac\left\{1\right\}\left\{z\right\}bigg\right]$
contains a positive integer.

## Identities

Most identities involving Fibonacci numbers draw from combinatorial arguments. F(n) can be interpreted as the number of ways summing 1's and 2's to n − 1, with the convention that F(0) = 0, meaning no sum will add up to −1, and that F(1) = 1, meaning the empty sum will "add up" to 0. Here the order of the summands matters. For example, 1 + 2 and 2 + 1 are considered two different sums and are counted twice.

### First Identity

$F_\left\{n+1\right\} = F_\left\{n\right\} + F_\left\{n-1\right\}$

The nth Fibonacci number is the sum of the previous two Fibonacci numbers.

#### Proof

We must establish that the sequence of numbers defined by the combinatorial interpretation above satisfy the same recurrence relation as the Fibonacci numbers (and so are indeed identical to the Fibonacci numbers).

The set of F(n+1) ways of making ordered sums of 1's and 2's that sum to n may be divided into two non-overlapping sets. The first set contains those sums whose first summand is 1; the remainder sums to n−1, so there are F(n) sums in the first set. The second set contains those sums whose first summand is 2; the remainder sums to n−2, so there are F(n−1) sums in the second set. The first summand can only be 1 or 2, so these two sets exhaust the original set. Thus F(n+1) = F(n) + F(n−1).

### Second Identity

$sum_\left\{i=0\right\}^n F_i = F_\left\{n+2\right\} - 1$

The sum of the first n Fibonacci numbers is the (n+2)nd Fibonacci number minus 1.

#### Proof

We count the number of ways summing 1's and 2's to n + 1 such that at least one of the summands is 2.

As before, there are F(n + 2) ways summing 1's and 2's to n + 1 when n ≥ 0. Since there is only one sum of n + 1 that does not use any 2, namely 1 + … + 1 (n + 1 terms), we subtract 1 from F(n + 2).

Equivalently, we can consider the first occurrence of 2 as a summand. If, in a sum, the first summand is 2, then there are F(n) ways to the complete the counting for n − 1. If the second summand is 2 but the first is 1, then there are F(n − 1) ways to complete the counting for n − 2. Proceed in this fashion. Eventually we consider the (n + 1)th summand. If it is 2 but all of the previous n summands are 1's, then there are F(0) ways to complete the counting for 0. If a sum contains 2 as a summand, the first occurrence of such summand must take place in between the first and (n + 1)th position. Thus F(n) + F(n − 1) + … + F(0) gives the desired counting.

### Third Identity

This identity has slightly different forms for $F_k$, depending on whether k is odd or even.

$sum_\left\{i=0\right\}^\left\{n-1\right\} F_\left\{2i+1\right\} = F_\left\{2n\right\}$
$sum_\left\{i=0\right\}^\left\{n\right\} F_\left\{2i\right\} = F_\left\{2n+1\right\}-1$

The sum of the first n-1 Fibonacci numbers, $F_j$, such that j is odd is the (2n)th Fibonacci number.
The sum of the first n Fibonacci numbers, $F_j$, such that j is even is the (2n+1)th Fibonacci number minus 1.

#### Proofs

By induction for $F_\left\{2n\right\}$:

$F_1+F_3+F_5+...+F_\left\{2n-3\right\}+F_\left\{2n-1\right\}=F_\left\{2n\right\}$
$F_1+F_3+F_5+...+F_\left\{2n-3\right\}+F_\left\{2n-1\right\}+F_\left\{2n+1\right\}=F_\left\{2n\right\}+F_\left\{2n+1\right\}$
$F_1+F_3+F_5+...+F_\left\{2n-3\right\}+F_\left\{2n-1\right\}+F_\left\{2n+1\right\}=F_\left\{2n+2\right\}$
A basis case for this could be $F_1=F_2$.
By induction for $F_\left\{2n+1\right\}$:
$F_0+F_2+F_4+...+F_\left\{2n-2\right\}+F_\left\{2n\right\}=F_\left\{2n+1\right\}-1$
$F_0+F_2+F_4+...+F_\left\{2n-2\right\}+F_\left\{2n\right\}+F_\left\{2n+2\right\}=F_\left\{2n+1\right\}+F_\left\{2n+2\right\}-1$
$F_0+F_2+F_4+...+F_\left\{2n-2\right\}+F_\left\{2n\right\}+F_\left\{2n+2\right\}=F_\left\{2n+3\right\}-1$
A basis case for this could be $F_0=F_1-1$.

### Fourth Identity

$sum_\left\{i=0\right\}^n iF_i = nF_\left\{n+2\right\} - F_\left\{n+3\right\} + 2$

#### Proof

This identity can be established in two stages. First, we count the number of ways summing 1s and 2s to −1, 0, …, or n + 1 such that at least one of the summands is 2.

By our second identity, there are F(n + 2) − 1 ways summing to n + 1; F(n + 1) − 1 ways summing to n; …; and, eventually, F(2) − 1 way summing to 1. As F(1) − 1 = F(0) = 0, we can add up all n + 1 sums and apply the second identity again to obtain

[F(n + 2) − 1] + [F(n + 1) − 1] + … + [F(2) − 1]
= [F(n + 2) − 1] + [F(n + 1) − 1] + … + [F(2) − 1] + [F(1) − 1] + F(0)
= F(n + 2) + [F(n + 1) + … + F(1) + F(0)] − (n + 2)
= F(n + 2) + [F(n + 3) − 1] − (n + 2)
= F(n + 2) + F(n + 3) − (n + 3).

On the other hand, we observe from the second identity that there are

• F(0) + F(1) + … + F(n − 1) + F(n) ways summing to n + 1;
• F(0) + F(1) + … + F(n − 1) ways summing to n;

……

• F(0) way summing to −1.

Adding up all n + 1 sums, we see that there are

• (n + 1) F(0) + n F(1) + … + F(n) ways summing to −1, 0, …, or n + 1.

Since the two methods of counting refer to the same number, we have

(n + 1) F(0) + n F(1) + … + F(n) = F(n + 2) + F(n + 3) − (n + 3)

Finally, we complete the proof by subtracting the above identity from n + 1 times the second identity.

### Fifth Identity

$sum_\left\{i=0\right\}^n \left\{F_i\right\}^2 = F_\left\{n\right\} F_\left\{n+1\right\}$

The sum of the first n Fibonacci numbers squared is the product of the nth and (n+1)th Fibonacci numbers.

### Identity for doubling n

$F_\left\{2n\right\} = F_\left\{n+1\right\}^2 - F_\left\{n-1\right\}^2 = F_n\left(F_\left\{n+1\right\}+F_\left\{n-1\right\}\right)$

### Another Identity

Another identity useful for calculating Fn for large values of n is

$F_\left\{kn+c\right\} = sum_\left\{i=0\right\}^k \left\{kchoose i\right\} F_\left\{c-i\right\} F_n^i F_\left\{n+1\right\}^\left\{k-i\right\},$

from which other identities for specific values of k, n, and c can be derived below, including

$F_\left\{2n+k\right\} = F_k F_\left\{n+1\right\}^2 + 2 F_\left\{k-1\right\} F_\left\{n+1\right\} F_n + F_\left\{k-2\right\} F_n^2$

for all integers n and k. Dijkstra points out that doubling identities of this type can be used to calculate Fn using O(log n) long multiplication operations of size n bits; if the fast Schönhage-Strassen multiplication algorithm is used, this is O(n log2 n log log n) bit operations. Notice that, with the definition of Fibonacci numbers with negative n given in the introduction, this formula reduces to the double n formula when k = 0.

### Other identities

Other identities include relationships to the Lucas numbers, which have the same recursive properties but start with L0=2 and L1=1. These properties include F2n=FnLn.

There are also scaling identities, which take you from Fn and Fn+1 to a variety of things of the form Fan+b; for instance

$F_\left\{3n\right\} = 2F_n^3 + 3F_n F_\left\{n+1\right\} F_\left\{n-1\right\} = 5F_\left\{n\right\}^3 + 3 \left(-1\right)^n F_\left\{n\right\}$ by Cassini's identity.

$F_\left\{3n+1\right\} = F_\left\{n+1\right\}^3 + 3 F_\left\{n+1\right\}F_n^2 - F_n^3$

$F_\left\{3n+2\right\} = F_\left\{n+1\right\}^3 + 3 F_\left\{n+1\right\}^2F_n + F_n^3$

$F_\left\{4n\right\} = 4F_nF_\left\{n+1\right\}\left(F_\left\{n+1\right\}^2 + 2F_n^2\right) - 3F_n^2\left(F_n^2 + 2F_\left\{n+1\right\}^2\right)$

These can be found experimentally using lattice reduction, and are useful in setting up the special number field sieve to factorize a Fibonacci number. Such relations exist in a very general sense for numbers defined by recurrence relations, see the section on multiplication formulae under Perrin numbers for details.

## Power series

The generating function of the Fibonacci sequence is the power series
$s\left(x\right)=sum_\left\{k=0\right\}^\left\{infty\right\} F_k x^k.$

This series has a simple and interesting closed-form solution for $|x| < 1/varphi$

$s\left(x\right)=frac\left\{x\right\}\left\{1-x-x^2\right\}.$

This solution can be proven by using the Fibonacci recurrence to expand each coefficient in the infinite sum defining $s\left(x\right)$:

begin\left\{align\right\}
s(x) &= sum_{k=0}^{infty} F_k x^k &= F_0 + F_1x + sum_{k=2}^{infty} left(F_{k-1} + F_{k-2} right) x^k &= x + sum_{k=2}^{infty} F_{k-1} x^k + sum_{k=2}^{infty} F_{k-2} x^k &= x + xsum_{k=0}^{infty} F_k x^k + x^2sum_{k=0}^{infty} F_k x^k
`      &= x + x s(x) + x^2 s(x)`
end{align}

Solving the equation $s\left(x\right)=x+xs\left(x\right)+x^2s\left(x\right)$ for $s\left(x\right)$ results in the closed form solution.

In particular, math puzzle-books note the curious value $frac\left\{s\left(frac\left\{1\right\}\left\{10\right\}\right)\right\}\left\{10\right\}=frac\left\{1\right\}\left\{89\right\}$, or more generally

$sum_\left\{n = 1\right\}^\left\{infty\right\}\left\{frac \left\{F\left(n\right)\right\}\left\{10^\left\{\left(k + 1\right)\left(n + 1\right)\right\}\right\}\right\} = frac \left\{1\right\}\left\{10^\left\{2k + 2\right\} - 10^\left\{k + 1\right\} - 1\right\}$

for all integers $k >= 0$.

Conversely,

$sum_\left\{n=0\right\}^infty,frac\left\{F_n\right\}\left\{k^\left\{n\right\}\right\},=,frac\left\{k\right\}\left\{k^\left\{2\right\}-k-1\right\}.$

## Reciprocal sums

Infinite sums over reciprocal Fibonacci numbers can sometimes be evaluated in terms of theta functions. For example, we can write the sum of every odd-indexed reciprocal Fibonacci number as

$sum_\left\{k=0\right\}^infty frac\left\{1\right\}\left\{F_\left\{2k+1\right\}\right\} = frac\left\{sqrt\left\{5\right\}\right\}\left\{4\right\}vartheta_2^2 left\left(0, frac\left\{3-sqrt 5\right\}\left\{2\right\}right\right) ,$

and the sum of squared reciprocal Fibonacci numbers as

$sum_\left\{k=1\right\}^infty frac\left\{1\right\}\left\{F_k^2\right\} = frac\left\{5\right\}\left\{24\right\} left\left(vartheta_2^4left\left(0, frac\left\{3-sqrt 5\right\}\left\{2\right\}right\right) - vartheta_4^4left\left(0, frac\left\{3-sqrt 5\right\}\left\{2\right\}right\right) + 1 right\right).$

If we add 1 to each Fibonacci number in the first sum, there is also the closed form

$sum_\left\{k=0\right\}^infty frac\left\{1\right\}\left\{1+F_\left\{2k+1\right\}\right\} = frac\left\{sqrt\left\{5\right\}\right\}\left\{2\right\},$

and there is a nice nested sum of squared Fibonacci numbers giving the reciprocal of the golden ratio,

$sum_\left\{k=1\right\}^infty frac\left\{\left(-1\right)^\left\{k+1\right\}\right\}\left\{sum_\left\{j=1\right\}^k \left\{F_\left\{j\right\}\right\}^2\right\} = frac\left\{sqrt\left\{5\right\}-1\right\}\left\{2\right\}.$

Results such as these make it plausible that a closed formula for the plain sum of reciprocal Fibonacci numbers could be found, but none is yet known. Despite that, the reciprocal Fibonacci constant

$psi = sum_\left\{k=1\right\}^\left\{infty\right\} frac\left\{1\right\}\left\{F_k\right\} = 3.359885666243 dots$

has been proved irrational by Richard André-Jeannin.

## Primes and divisibility

A Fibonacci prime is a Fibonacci number that is prime . The first few are:
2, 3, 5, 13, 89, 233, 1597, 28657, 514229, …
Fibonacci primes with thousands of digits have been found, but it is not known whether there are infinitely many. They must all have a prime index, except F4 = 3. There are arbitrarily long runs of composite numbers and therefore also of composite Fibonacci numbers.

With the exceptions of 1, 8 and 144 (F0 = F1, F6 and F12) every Fibonacci number has a prime factor that is not a factor of any smaller Fibonacci number (Carmichael's theorem). 0, 1, and 144 are also the only square Fibonacci numbers.

No Fibonacci number greater than F6 = 8 is one greater or one less than a prime number.

Any three consecutive Fibonacci numbers, taken two at a time, are relatively prime: that is,

gcd(Fn, Fn+1) = gcd(Fn, Fn+2) = 1.
More generally,
gcd(Fn, Fm) = Fgcd(n, m).

### Odd divisors

If n is odd all the odd divisors of Fn are ≡ 1 (mod 4).
This is equivalent to saying that for odd n all the odd prime factors of Fn are ≡ 1 (mod 4).

For example, F1 = 1, F3 = 2, F5 = 5, F7 = 13, F9 = 34 = 2×17, F11 = 89, F13 = 233, F15 = 610 = 2×5×61

### Fibonacci and Legendre

There are some interesting formulas connecting the Fibonacci numbers and the Legendre symbol $;left\left(tfrac\left\{p\right\}\left\{5\right\}right\right).$


left(frac{p}{5}right) = left { begin{array}{cl} 0 & textrm{if};p =5 1 &textrm{if};p equiv pm1 pmod 5 -1 &textrm{if};p equiv pm2 pmod 5 end{array} right.

If p is a prime number then $F_\left\{p\right\} equiv left\left(frac\left\{p\right\}\left\{5\right\}right\right) pmod p ;;mbox\left\{ and \right\};;; F_\left\{p-left\left(frac\left\{p\right\}\left\{5\right\}right\right)\right\} equiv 0 pmod p.$

For example,

$\left(tfrac\left\{2\right\}\left\{5\right\}\right) = -1, ,, F_3 = 2, F_2=1,$
$\left(tfrac\left\{3\right\}\left\{5\right\}\right) = -1, ,, F_4 = 3,F_3=2,$
$\left(tfrac\left\{5\right\}\left\{5\right\}\right) = ;;,0,,, F_5 = 5,$
$\left(tfrac\left\{7\right\}\left\{5\right\}\right) = -1, ,,F_8 = 21,;;F_7=13,$
$\left(tfrac\left\{11\right\}\left\{5\right\}\right) = +1, F_\left\{10\right\} = 55, F_\left\{11\right\}=89.$

Also, if p ≠ 5 is an odd prime number then:

$5F^2_\left\{left\left(p pm 1 right\right) / 2\right\}$
equiv begin{cases} frac{5left(frac{p}{5}right)pm 5}{2} pmod p & textrm{if};p equiv 1 pmod 4 frac{5left(frac{p}{5}right)mp 3}{2} pmod p & textrm{if};p equiv 3 pmod 4 end{cases}

Examples of all the cases:

$p=7 equiv 3 pmod 4, ;;\left(tfrac\left\{7\right\}\left\{5\right\}\right) = -1, frac\left\{5\left(frac\left\{7\right\}\left\{5\right\}\right)+3\right\}\left\{2\right\} =-1mbox\left\{ and \right\}frac\left\{5\left(frac\left\{7\right\}\left\{5\right\}\right)-3\right\}\left\{2\right\}=-4.$
$F_3=2 mbox\left\{ and \right\} F_4=3.$

$5F_3^2=20equiv -1 pmod \left\{7\right\};;mbox\left\{ and \right\};;5F_4^2=45equiv -4 pmod \left\{7\right\}$

$p=11 equiv 3 pmod 4, ;;\left(tfrac\left\{11\right\}\left\{5\right\}\right) = +1, frac\left\{5\left(frac\left\{11\right\}\left\{5\right\}\right)+3\right\}\left\{2\right\} =4mbox\left\{ and \right\}frac\left\{5\left(frac\left\{11\right\}\left\{5\right\}\right)- 3\right\}\left\{2\right\}=1.$
$F_5=5 mbox\left\{ and \right\} F_6=8.$

$5F_5^2=125equiv 4 pmod \left\{11\right\} ;;mbox\left\{ and \right\};;5F_6^2=320equiv 1 pmod \left\{11\right\}$

$p=13 equiv 1 pmod 4, ;;\left(tfrac\left\{13\right\}\left\{5\right\}\right) = -1, frac\left\{5\left(frac\left\{13\right\}\left\{5\right\}\right)-5\right\}\left\{2\right\} =-5mbox\left\{ and \right\}frac\left\{5\left(frac\left\{13\right\}\left\{5\right\}\right)+ 5\right\}\left\{2\right\}=0.$
$F_6=8 mbox\left\{ and \right\} F_7=13.$

$5F_6^2=320equiv -5 pmod \left\{13\right\} ;;mbox\left\{ and \right\};;5F_7^2=845equiv 0 pmod \left\{13\right\}$

$p=29 equiv 1 pmod 4, ;;\left(tfrac\left\{29\right\}\left\{5\right\}\right) = +1, frac\left\{5\left(frac\left\{29\right\}\left\{5\right\}\right)-5\right\}\left\{2\right\} =0mbox\left\{ and \right\}frac\left\{5\left(frac\left\{29\right\}\left\{5\right\}\right)+5\right\}\left\{2\right\}=5.$
$F_\left\{14\right\}=377 mbox\left\{ and \right\} F_\left\{15\right\}=610.$

$5F_\left\{14\right\}^2=710645equiv 0 pmod \left\{29\right\} ;;mbox\left\{ and \right\};;5F_\left\{15\right\}^2=1860500equiv 5 pmod \left\{29\right\}$

### Divisibility by 11

$sum_\left\{k=n\right\}^\left\{n+9\right\} F_\left\{k\right\} = 11 F_\left\{n+6\right\}$

For example, let n = 1:
F1+F2+...+F10 = 1 + 1 + 2 + 3 + 5 + 8 + 13 + 21 + 34 + 55 = 143 = 11×13
n = 2:
F2+F3+...+F11 = 1 + 2 + 3 + 5 + 8 + 13 + 21 + 34 + 55 + 89 = 231 = 11×21
n = 3:
F3+F4+...+F12 = 2 + 3 + 5 + 8 + 13 + 21 + 34 + 55 + 89 + 144= 374 = 11×34

In fact, the identity is true for all integers n, not just positive ones:

n = 0:

F0+F1+...+F9 = 0 + 1 + 1 + 2 + 3 + 5 + 8 + 13 + 21 + 34 = 88 = 11×8
n = −1:

F−1+F0+...+F8 = 1 + 0 + 1 + 1 + 2 + 3 + 5 + 8 + 13 + 21 = 55 = 11×5
n = −2:

F−2+F−1+F0+...+F7 = −1 + 1 + 0 + 1 + 1 + 2 + 3 + 5 + 8 + 13 = 33 = 11×3

## Right triangles

Starting with 5, every second Fibonacci number is the length of the hypotenuse of a right triangle with integer sides, or in other words, the largest number in a Pythagorean triple. The length of the longer leg of this triangle is equal to the sum of the three sides of the preceding triangle in this series of triangles, and the shorter leg is equal to the difference between the preceding bypassed Fibonacci number and the shorter leg of the preceding triangle.

The first triangle in this series has sides of length 5, 4, and 3. Skipping 8, the next triangle has sides of length 13, 12 (5 + 4 + 3), and 5 (8 − 3). Skipping 21, the next triangle has sides of length 34, 30 (13 + 12 + 5), and 16 (21 − 5). This series continues indefinitely. The triangle sides a, b, c can be calculated directly:

$displaystyle a_n = F_\left\{2n-1\right\}$
$displaystyle b_n = 2 F_n F_\left\{n-1\right\}$
$displaystyle c_n = \left\{F_n\right\}^2 - \left\{F_\left\{n-1\right\}\right\}^2$

These formulas satisfy $a_n ^2 = b_n ^2 + c_n ^2$ for all n, but they only represent triangle sides when $n > 2$.

Any four consecutive Fibonacci numbers Fn, Fn+1, Fn+2 and Fn+3 can also be used to generate a Pythagorean triple in a different way:

$a = F_n F_\left\{n+3\right\} , ; , b = 2 F_\left\{n+1\right\} F_\left\{n+2\right\} , ; , c = F_\left\{n+1\right\}^2 + F_\left\{n+2\right\}^2 , ; , a^2 + b^2 = c^2 ,.$
Example 1: let the Fibonacci numbers be 1, 2, 3 and 5. Then:
$displaystyle a = 1 times 5 = 5$
$displaystyle b = 2 times 2 times 3 = 12$
$displaystyle c = 2^2 + 3^2 = 13 ,$
$displaystyle 5^2 + 12^2 = 13^2 ,.$
Example 2: let the Fibonacci numbers be 8, 13, 21 and 34. Then:
$displaystyle a = 8 times 34 = 272$
$displaystyle b = 2 times 13 times 21 = 546$
$displaystyle c = 13^2 + 21^2 = 610 ,$
$displaystyle 272^2 + 546^2 = 610^2 ,.$

## Magnitude of Fibonacci numbers

Since $F_n$ is asymptotic to $varphi^n/sqrt5$, the number of digits in the base b representation of $F_n,$ is asymptotic to $n,log_bvarphi$.

For every integer d greater than 1 there are either 4 or 5 Fibonacci numbers with d digits in base 10.

## Applications

The Fibonacci numbers are important in the run-time analysis of Euclid's algorithm to determine the greatest common divisor of two integers: the worst case input for this algorithm is a pair of consecutive Fibonacci numbers.

Yuri Matiyasevich was able to show that the Fibonacci numbers can be defined by a Diophantine equation, which led to his original solution of Hilbert's tenth problem.

The Fibonacci numbers occur in the sums of "shallow" diagonals in Pascal's triangle and Lozanić's triangle (see "Binomial coefficient"). (They occur more obviously in Hosoya's triangle).

Every positive integer can be written in a unique way as the sum of one or more distinct Fibonacci numbers in such a way that the sum does not include any two consecutive Fibonacci numbers. This is known as Zeckendorf's theorem, and a sum of Fibonacci numbers that satisfies these conditions is called a Zeckendorf representation.

The Fibonacci numbers and principle is also used in the financial markets. It is used in trading algorithms, applications and strategies. Some typical forms include: the Fibonacci fan, Fibonacci Arc, Fibonacci Retracement and the Fibonacci Time Extension.

Fibonacci numbers are used by some pseudorandom number generators.

Fibonacci numbers are used in a polyphase version of the merge sort algorithm in which an unsorted list is divided into two lists whose lengths correspond to sequential Fibonacci numbers - by dividing the list so that the two parts have lengths in the approximate proportion φ. A tape-drive implementation of the polyphase merge sort was described in The Art of Computer Programming.

Fibonacci numbers arise in the analysis of the Fibonacci heap data structure.

A one-dimensional optimization method, called the Fibonacci search technique, uses Fibonacci numbers.

The Fibonacci number series is used for optional lossy compression in the IFF 8SVX audio file format used on Amiga computers. The number series compands the original audio wave similar to logarithmic methods e.g. µ-law.

In music, Fibonacci numbers are sometimes used to determine tunings, and, as in visual art, to determine the length or size of content or formal elements. It is commonly thought that the first movement of Béla Bartók's Music for Strings, Percussion, and Celesta was structured using Fibonacci numbers.

Since the conversion factor 1.609344 for miles to kilometers is close to the golden ratio (denoted φ), the decomposition of distance in miles into a sum of Fibonacci numbers becomes nearly the kilometer sum when the Fibonacci numbers are replaced by their successors. This method amounts to a radix 2 number register in golden ratio base φ being shifted. To convert from kilometers to miles, shift the register down the Fibonacci sequence instead.

## Fibonacci numbers in nature

Fibonacci sequences appear in biological settings, in two consecutive Fibonacci numbers, such as branching in trees, arrangement of leaves on a stem, the fruitlets of a pineapple, the flowering of artichoke, an uncurling fern and the arrangement of a pine cone. In addition, numerous poorly substantiated claims of Fibonacci numbers or golden sections in nature are found in popular sources, e.g. relating to the breeding of rabbits, the spirals of shells, and the curve of waves. The Fibonacci numbers are also found in the family tree of honeybees.

Przemyslaw Prusinkiewicz advanced the idea that real instances can be in part understood as the expression of certain algebraic constraints on free groups, specifically as certain Lindenmayer grammars.

A model for the pattern of florets in the head of a sunflower was proposed by H. Vogel in 1979. This has the form

$theta = frac\left\{2pi\right\}\left\{phi^2\right\} n$, $r = c sqrt\left\{n\right\}$
where n is the index number of the floret and c is a constant scaling factor; the florets thus lie on Fermat's spiral. The divergence angle, approximately 137.51°, is the golden angle, dividing the circle in the golden ratio. Because this ratio is irrational, no floret has a neighbor at exactly the same angle from the center, so the florets pack efficiently. Because the rational approximations to the golden ratio are of the form F(j):F(j+1), the nearest neighbors of floret number n are those at n±F(j) for some index j which depends on r, the distance from the center. It is often said that sunflowers and similar arrangements have 55 spirals in one direction and 89 in the other (or some other pair of adjacent Fibonacci numbers), but this is true only of one range of radii, typically the outermost and thus most conspicuous.

## Generalizations

The Fibonacci sequence has been generalized in many ways. These include:

• Generalizing the index to negative integers to produce the Negafibonacci numbers.
• Generalizing the index to real numbers using a modification of Binet's formula.
• Starting with other integers. Lucas numbers have L1 = 1, L2 = 3, and Ln = Ln−1 + Ln−2. Primefree sequences use the Fibonacci recursion with other starting points in order to generate sequences in which all numbers are composite.
• Letting a number be a linear function (other than the sum) of the 2 preceding numbers. The Pell numbers have Pn = 2Pn – 1 + Pn – 2.
• Not adding the immediately preceding numbers. The Padovan sequence and Perrin numbers have P(n) = P(n – 2) + P(n – 3).
• Generating the next number by adding 3 numbers (tribonacci numbers), 4 numbers (tetranacci numbers), or more.
• Adding other objects than integers, for example functions or strings -- one essential example is Fibonacci polynomials.

## Numbers properties

### Periodicity mod n: Pisano periods

It is easily seen that if the members of the Fibonacci sequence are taken mod n, the resulting sequence must be periodic with period at most $n^2$. The lengths of the periods for various n form the so-called Pisano periods . Determining the Pisano periods in general is an open problem, although for any particular n it can be solved as an instance of cycle detection.

## The bee ancestry code

Fibonacci numbers also appear in the description of the reproduction of a population of idealized bees, according to the following rules:

• If an egg is laid by an unmated female, it hatches a male.
• If, however, an egg was fertilized by a male, it hatches a female.

Thus, a male bee will always have one parent, and a female bee will have two.

If one traces the ancestry of any male bee (1 bee), he has 1 female parent (1 bee). This female had 2 parents, a male and a female (2 bees). The female had two parents, a male and a female, and the male had one female (3 bees). Those two females each had two parents, and the male had one (5 bees). This sequence of numbers of parents is the Fibonacci sequence.

This is an idealization that does not describe actual bee ancestries. In reality, some ancestors of a particular bee will always be sisters or brothers, thus breaking the lineage of distinct parents.