Fibonacci Calculator: nth Term, Sums, Lucas Numbers and Tests
By FindMySum · Last reviewed
The Fibonacci sequence starts 0, 1, and every later term is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144… This calculator finds any term exactly, up to F(10,000), a number with 2,090 digits. It also lists a run of terms and their sum, tells you whether a number belongs to the sequence, and handles the Lucas numbers and any sequence with your own two starting values.
The rule and the numbering
F(0) = 0, F(1) = 1, F(n) = F(n − 1) + F(n − 2)
The calculator follows the numbering of OEIS A000045, the standard reference, so F(0) = 0, F(1) = 1, F(2) = 1, F(3) = 2. If your textbook starts with F(1) = 1, F(2) = 1, its numbers match these. If it starts with F(1) = 0, subtract one from its index.
Worked example: the default
The calculator opens with n = 20:
| n | 15 | 16 | 17 | 18 | 19 | 20 |
|---|---|---|---|---|---|---|
| F(n) | 610 | 987 | 1,597 | 2,584 | 4,181 | 6,765 |
So F(20) = 6,765. The sum of all the terms from F(0) to F(20) is F(22) − 1 = 17,711 − 1 = 17,710, and the ratio 6,765 ÷ 4,181 = 1.6180339632, already within 0.00000003 of the golden ratio.
How large terms are computed exactly
Adding terms one at a time works, but the calculator uses the fast doubling identities:
F(2k) = F(k) × (2F(k + 1) − F(k)) F(2k + 1) = F(k)² + F(k + 1)²
Each step doubles the index, so F(10,000) needs about 14 steps instead of 10,000 additions. All arithmetic uses whole numbers of unlimited length, so every digit is exact. A spreadsheet or a calculator using ordinary floating point loses exactness at F(79), the first term above 2⁵³.
The sum of the terms
There is a neat shortcut for the running total:
F(0) + F(1) + … + F(n) = F(n + 2) − 1
You can see why by adding 1 = F(1) to the sum: F(1) + F(0) + F(1) = F(2) + F(1) = F(3), then + F(2) gives F(4), and so on until the whole sum collapses to F(n + 2). The same argument shows that for any sequence with the Fibonacci rule, the sum from term 0 to term n is term n + 2 minus term 1. In list mode, the calculator sums exactly the terms shown.
Binet's formula and the golden ratio
The Fibonacci numbers have a closed form, named after Jacques Binet:
F(n) = (φⁿ − ψⁿ) ÷ √5, with φ = (1 + √5) ÷ 2 ≈ 1.618034 and ψ = (1 − √5) ÷ 2 ≈ −0.618034
Because |ψ| is less than 1, ψⁿ shrinks to nothing, and F(n) is simply φⁿ ÷ √5 rounded to the nearest whole number. That is why the ratio of consecutive terms approaches φ, and why each term has, on average, about 0.209 more digits than the one before (log₁₀ φ ≈ 0.20899). The calculator shows Binet's value next to the exact one for terms small enough to fit in ordinary decimal arithmetic.
Is a number in the sequence?
A whole number x is a Fibonacci number exactly when at least one of 5x² + 4 and 5x² − 4 is a perfect square. For x = 144, 5 × 144² + 4 = 103,684 = 322², so 144 is a Fibonacci number, F(12). For x = 150, neither 112,504 nor 112,496 is a square, so 150 is not; the calculator also finds its neighbours, F(12) = 144 and F(13) = 233. For Lucas and custom sequences, which the square test does not cover, it searches the sequence directly.
Lucas numbers and custom starts
Keep the rule, change the starting values, and you get a different sequence. Starting with 2 and 1 gives the Lucas numbers, 2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123…, which share most of the Fibonacci numbers' properties, for example L(n) = F(n − 1) + F(n + 1) and F(2n) = F(n) × L(n). Any other start a, b gives the sequence a·F(n − 1) + b·F(n), and its consecutive ratios also approach φ.
Fibonacci numbers in the world
- Plants: the number of spirals in sunflower heads, pine cones and pineapples is usually a Fibonacci number, because each new seed grows at about 137.5° (the golden angle) from the last.
- Computer science: Fibonacci heaps, Fibonacci search and the worst case of Euclid's algorithm (consecutive Fibonacci numbers take the most steps) all come from the sequence.
- Agile planning: story points of 1, 2, 3, 5, 8, 13 use the growing gaps to signal that bigger estimates are less precise.
- Unit conversion: consecutive Fibonacci numbers give a quick miles-to-kilometres rule (5 mi ≈ 8 km, 8 mi ≈ 13 km), because φ is close to 1.609.
More questions
Is 0 a Fibonacci number?
In the modern convention used by OEIS and most mathematics texts, yes: F(0) = 0. Some older books and puzzles start the sequence at 1, 1. The values are the same either way; only the numbering of the terms changes.
Are there infinitely many Fibonacci primes?
Nobody knows. Fibonacci primes such as 2, 3, 5, 13, 89, 233 and 1597 keep appearing, but whether there are infinitely many is an open problem. A useful fact: F(n) can only be prime when n is prime (or n = 4), though most prime n do not give a prime.
Do Fibonacci numbers really appear in nature?
Some do, convincingly: the spiral counts in sunflower heads and pine cones are usually consecutive Fibonacci numbers such as 34 and 55, a result of how new seeds are packed at a constant angle. Many popular claims, about the human body, the Parthenon or nautilus shells, do not hold up when measured.
What is the Fibonacci retracement used in trading?
Chart analysts draw horizontal lines at 23.6%, 38.2%, 61.8% and similar fractions of a price move, taken from ratios of Fibonacci numbers. These are conventions of technical analysis, not consequences of the mathematics, and there is little evidence that prices respect them.
Why do programmers compute Fibonacci numbers?
It is the standard first example of recursion and of why naive recursion is slow: computing F(n) by calling F(n − 1) and F(n − 2) repeats work exponentially. Memoisation, iteration and fast doubling show how a better algorithm turns an impossible computation into an instant one.
Sources
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.