The Fibonacci sequence is one of the most recognisable patterns in mathematics. Starting from 0 and 1, every subsequent number is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, … The sequence turns up in sunflower seed spirals, nautilus shells, tree branching patterns, financial Elliott-wave analysis, and the analysis of algorithms. This calculator lets you find any term instantly, copy the full exact integer (even when it runs to hundreds of digits), explore how the ratio of consecutive terms converges to the golden ratio phi, and see the classic rectangle spiral drawn as an SVG.
How it works
The calculator uses the fast-doubling algorithm, a divide-and-conquer method
that computes F(n) in O(log n) arithmetic operations using two variables and
JavaScript’s built-in BigInt type for perfect precision. It relies on the
identities:
F(2k) = F(k) * (2*F(k+1) - F(k))
F(2k+1) = F(k)^2 + F(k+1)^2
Starting from F(0) = 0 and F(1) = 1, the algorithm reads the binary representation of n from the most-significant bit down, halving the problem at each step. This is far faster than the naive recurrence loop for large n — reaching F(10,000) in milliseconds where a loop would need ten thousand additions of increasingly large BigInts.
For small n (up to 78) the tool also shows the Binet / closed-form approximation:
F(n) = round( phi^n / sqrt(5) )
where phi = (1 + sqrt(5)) / 2 is the golden ratio. Beyond n = 78 floating-point precision is exhausted, so only the exact BigInt result is shown.
Worked example
Find F(10):
- Start: F(0) = 0, F(1) = 1
- Apply the recurrence eight more times: F(2) = 1, F(3) = 2, F(4) = 3, F(5) = 5, F(6) = 8, F(7) = 13, F(8) = 21, F(9) = 34
- F(10) = F(9) + F(8) = 34 + 21 = 55
Closed-form check: phi^10 / sqrt(5) = 1.6180^10 / 2.2360 = 122.99 / 2.236 = 55.00. Rounds to 55. Exact.
| n | F(n) | Ratio F(n)/F(n-1) | Digits |
|---|---|---|---|
| 5 | 5 | 1.6667 | 1 |
| 10 | 55 | 1.6182 | 2 |
| 20 | 6,765 | 1.61804 | 4 |
| 50 | 12,586,269,025 | 1.6180339887 | 11 |
| 100 | 354,224,848,179,261,915,075 | 1.61803398875 | 21 |
| 1000 | (209-digit integer) | phi to 15 decimal places | 209 |
Formula note
The general term can also be expressed using the conjugate root psi = (1 - sqrt(5)) / 2 as the exact closed form:
F(n) = ( phi^n - psi^n ) / sqrt(5)
Because |psi| is less than 1 (approximately -0.618), the term psi^n becomes negligibly small for large n and the formula reduces to the rounding version above. This is Binet’s formula, published in 1843, though Abraham de Moivre knew an equivalent form a century earlier.
Every calculation runs entirely in your browser using native BigInt arithmetic.
No numbers are sent to a server or stored anywhere.