All topics
Foundational

Number theory · growth, the golden ratio and nature

Fibonacci Sequence Calculator

Start with 1 and 1, then keep adding the last two numbers: 1, 1, 2, 3, 5, 8, 13. A rule a child can follow, yet it sets the spiral of a shell, the seeds of a sunflower, and a number that has fascinated people for centuries.

Click to begin

Explained like you're twelve. Explained like you've just finished school. Explained like you're at university.

By . Last updated .

Number theory · Open: are there infinitely many Fibonacci primes?

Add the last two and never stop. The sequence that grows like a plant and homes in on the golden ratio.

Fibonacci sequence calculator

Each term is the sum of the two before it, \(F_n = F_{n-1} + F_{n-2}\), starting \(F_0 = 0,\ F_1 = 1\). The ratio \(F_n/F_{n-1}\) closes in on the golden ratio \(\varphi \approx 1.618\).

Fₙ
Ratio Fₙ / Fₙ₋₁
Sequence
The sequence is exact for any n up to 1000, however many digits it takes. Divide any term by the one before it and the answer settles onto the golden ratio almost at once, which is why Fibonacci numbers keep turning up wherever nature packs things efficiently.
In Sunflower mode each seed sits one turn of the angle from the last. Land on the golden angle, near 137.5 degrees, and the seeds pack with no gaps and no seams; the spiral arms your eye traces count in Fibonacci numbers. Move the slider a hair off it and the packing breaks into spokes. Switch to Golden ratio mode to watch each ratio of neighbouring Fibonacci numbers bounce above and below the golden ratio and settle onto it.

What is the Fibonacci sequence?

The Fibonacci sequence is one of the most famous patterns in maths, and the rule behind it is tiny. Start with 1 and 1. To get the next number, add the last two together. So 1 and 1 make 2. Then 1 and 2 make 3. Then 2 and 3 make 5. Keep going and you get 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, and on forever.

What makes it special is where it turns up. Count the petals on a lot of flowers and you tend to land on a Fibonacci number. The seeds in a sunflower, the bumps on a pinecone, the bracts on a pineapple all spiral in counts that come from this sequence. It is not magic. It is the most efficient way for a plant to pack new parts in as it grows, and the maths of the sequence happens to describe that packing.

There is also a special number hiding inside it. Take any Fibonacci number and divide it by the one before. The answers, 2, then 1.5, then about 1.667, then 1.6, then 1.625, keep getting closer to a single value: roughly 1.618. People call it the golden ratio, and it has shown up in art and architecture for a very long time.

The widget above shows both sides. Tune the angle and watch a sunflower head form when you hit the right value, then switch modes and watch the ratios close in on 1.618. The Fibonacci sequence calculator at the very top gives the exact numbers: type any n and it returns the nth term and that same ratio.

Where does the Fibonacci sequence appear in nature?

The sequence is defined by a rule that points back at itself. Write \(F_1 = 1\), \(F_2 = 1\), and then every term after that is the sum of the two before it:

\[ F_n = F_{n-1} + F_{n-2}. \]

That gives 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 and onward. It was written down in Europe by Leonardo of Pisa, known as Fibonacci, in 1202, in a problem about breeding rabbits, though Indian scholars had studied the same numbers centuries earlier while counting rhythms in poetry.

The golden ratio

Divide each term by the one before and the ratios settle down:

\[ \frac{F_{n+1}}{F_n} \longrightarrow \varphi = \frac{1+\sqrt{5}}{2} \approx 1.6180. \]

This number \(\varphi\) is the golden ratio. It is the one value where a rectangle, with a square cut off it, leaves a smaller rectangle of exactly the same shape. The ratios in Golden ratio mode overshoot and undershoot it, getting closer with every step.

A formula with no counting

You do not have to grind through every term to find the hundredth one. There is a closed form, Binet's formula, that gives \(F_n\) directly:

\[ F_n = \frac{\varphi^n - (1-\varphi)^n}{\sqrt{5}}. \]

It looks like it should give a messy decimal, since it is built from \(\sqrt{5}\), yet the irrational parts always cancel and leave a whole number.

Why plants use it

A growing tip lays down each new seed or leaf turned a fixed angle from the last. If that angle is a simple fraction of a circle, the parts line up in spokes and waste space. The angle that never lines up, because it is built from the golden ratio, is about 137.5 degrees, the golden angle. Turning by it drops each seed into the largest remaining gap, which is why a sunflower head packs so tightly, and why the spiral arms you can count come out as Fibonacci numbers.

The Fibonacci sequence and the golden ratio

Where Binet's formula comes from

The recurrence \(F_n = F_{n-1} + F_{n-2}\) is linear, so look for solutions of the form \(x^n\). Substituting gives the characteristic equation \(x^2 = x + 1\), whose roots are \(\varphi = \tfrac{1+\sqrt5}{2}\) and \(\psi = \tfrac{1-\sqrt5}{2}\). Every solution is a combination \(A\varphi^n + B\psi^n\); fixing the constants to match \(F_1 = F_2 = 1\) gives \(F_n = (\varphi^n - \psi^n)/\sqrt5\). Since \(|\psi| \approx 0.618 < 1\), the \(\psi^n\) term shrinks to nothing, so \(F_n\) is just \(\varphi^n/\sqrt5\) rounded to the nearest integer, and the ratio of consecutive terms tends to \(\varphi\).

Identities and a matrix

The sequence is laced with exact relations. Cassini's identity, \(F_{n-1}F_{n+1} - F_n^2 = (-1)^n\), says consecutive terms only ever miss being a perfect product by one. The clean way to see the structure is the matrix form: \(\begin{pmatrix}1&1\\1&0\end{pmatrix}^n = \begin{pmatrix}F_{n+1}&F_n\\F_n&F_{n-1}\end{pmatrix}\), which makes Cassini fall straight out of the determinant and lets you compute \(F_n\) in a logarithmic number of steps by fast exponentiation.

Deep divisibility

The Fibonacci numbers carry a remarkable arithmetic: \(\gcd(F_m, F_n) = F_{\gcd(m,n)}\). The greatest common divisor of two Fibonacci numbers is itself a Fibonacci number, the one indexed by the gcd of the positions. It follows that \(F_m\) divides \(F_n\) exactly when \(m\) divides \(n\). Taken modulo any number the sequence is eventually periodic, and the length of that cycle is the Pisano period. Every positive integer also has a unique Zeckendorf representation, a sum of non-consecutive Fibonacci numbers, a kind of base built from the sequence.

What stays open

Not everything is settled. A Fibonacci prime is a term that is prime, like 2, 3, 5, 13, 89, 233. They thin out as you go, and whether the list of them is endless is unknown, an open problem with no proof either way. The golden ratio itself has a clean reason for sitting at the heart of all this: its continued fraction is \([1;1,1,1,\dots]\), all ones, which makes it in a precise sense the hardest number to approximate by fractions. That is exactly the property a plant wants in a divergence angle, so the appearance of \(\varphi\) in phyllotaxis is not a coincidence but the optimum, the same fact dressed in leaves. The link runs on into calculus through limits and into the rest of number theory.

Related: The Twin Prime Conjecture · next: Goldbach's Conjecture · or go back to all topics.

Sources