Fibonacci Calculator
Enter the first two terms and n to find the nth term of the sequence.
What the Fibonacci sequence is
This calculator finds the nth term of a Fibonacci-style sequence: a sequence where every term after the first two is the sum of the two before it. With the standard seeds F(0) = 0 and F(1) = 1, the sequence runs 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, and term 10 evaluates to 55. Change the two seeds and the same recurrence produces a different but equally well-defined sequence.
How the recurrence builds the answer
The calculator starts from your two seeds and applies the recurrence forward, one term at a time, until it reaches index n. Nothing is looked up from a table: F(2) = F(1) + F(0), F(3) = F(2) + F(1), and so on. This iterative approach runs in n simple additions, which is why it handles n up to 1476 instantly. Beyond that, JavaScript floating-point numbers can no longer represent the exact integer.
The seeds matter as much as the recurrence. F(0) = 0, F(1) = 1 gives the classical Fibonacci sequence. F(0) = 2, F(1) = 1 gives the Lucas sequence, which runs 2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, so L(10) = 123. F(0) = 1, F(1) = 2 gives a shifted Fibonacci often used in combinatorics. The ratios between consecutive terms converge to the same golden ratio in all three cases, because the seeds wash out as n grows.
Worked example with the default inputs
With F(0) = 0 and F(1) = 1, walk forward ten additions: F(2) = 0 + 1 = 1, F(3) = 1 + 1 = 2, F(4) = 2 + 1 = 3, F(5) = 3 + 2 = 5, F(6) = 5 + 3 = 8, F(7) = 8 + 5 = 13, F(8) = 13 + 8 = 21, F(9) = 21 + 13 = 34, F(10) = 34 + 21 = 55. Each step uses the two previous results, so only the two most recent terms ever need to be stored.
Growth is explosive beyond this point. F(12) = 144, F(20) = 6,765, and F(30) = 832,040. A useful identity for checking your work: F(0) + F(1) + … + F(n) = F(n + 2) − 1, so the sum of all terms through F(10) is F(12) − 1 = 143, which catches indexing errors quickly.
Terms of the standard sequence
| Index n | F(n) | Ratio F(n) ÷ F(n − 1) |
|---|---|---|
| 5 | 5 | 1.667 |
| 10 | 55 | 1.618 |
| 15 | 610 | 1.618 |
| 20 | 6,765 | 1.618 |
The ratio column shows the convergence to the golden ratio φ ≈ 1.618034. By index 15 the ratio matches φ to four decimal places, and every term after that satisfies F(n) ≈ φn ÷ √5. Checking index 10: 1.61803410 ÷ 2.236068 ≈ 55.0, matching the exact value.
What the numbers are used for
- Algorithm analysis: recursive Fibonacci is the textbook example of exponential blow-up, taking about 1.618n calls, while the iterative version this calculator uses takes n steps.
- The golden ratio in design and art: F(n)/F(n − 1) approximates φ, so the sequence supplies rational approximations such as 55/34 ≈ 1.6176.
- Trading retracement levels: chartists convert the ratios 23.6%, 38.2%, 61.8% and 100% into support levels, all derived from Fibonacci term ratios.
- Combinatorics: F(n + 1) counts the ways to tile a 1 × n strip with 1 × 1 and 1 × 2 tiles, so 13 arrangements exist for a strip of length 6.
- Computer science structures: Fibonacci heaps and Fibonacci search use the sequence’s growth rate to bound work per operation.
Custom seeds in practice
Setting F(0) = 2 and F(1) = 1 produces the Lucas numbers used in number theory identities. Setting F(0) = 1 and F(1) = 3 answers the classic rabbit-population style recurrence with a head start. Any two seeds produce a valid sequence, and the calculator treats negative seeds the same way, so F(0) = −1, F(1) = 1 yields −1, 1, 0, 1, 1, 2, 3, 5 and rejoins the standard sequence from F(3) onward.
Common mistakes
- Off-by-one indexing: some references start the sequence at F(1) = 1 with no F(0), which shifts every index down by one. This calculator indexes from F(0), so F(10) = 55, not 34.
- Confusing term count with index: asking for the 10th term when you mean F(10) gives different answers if you count F(1) as the first term. Check which convention your source uses before comparing results.
- Assuming exact doubling: the sequence grows by a factor of about 1.618 per step, not 2, so F(20) is 6,765, roughly half of 213.
- Expecting closed-form precision at large n: Binet’s formula F(n) ≈ φn ÷ √5 drifts by rounding at large n, while the iterative sum stays exact up to the 1476 limit.
Limits and precision
Why the cap sits at 1476
The input cap of n = 1476 is set by number size, not time: the iterative loop could run further, but Fibonacci numbers past that point exceed what a 64-bit floating-point mantissa can represent exactly, and trailing digits would silently turn wrong. Every result up to the cap is an exact integer with no rounding. If you need term 2000 or beyond, a big-integer library or a symbolic algebra tool is the right instrument, because the exact value of F(2000) has about 418 digits.
How this relates to other sequences
The Fibonacci recurrence is one member of the family where each term combines previous terms with fixed coefficients. An arithmetic sequence adds a constant instead of the previous term, and a geometric sequence multiplies by a constant; both are covered by the arithmetic sequence calculator and the geometric sequence calculator. The distinguishing feature here is that growth accelerates: the gap between consecutive terms, 55 − 34 = 21 at index 10, is itself a Fibonacci number.
Frequently asked questions
What is F(10) in the Fibonacci sequence?
F(10) = 55 with the standard seeds F(0) = 0 and F(1) = 1. Counting forward: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, where 55 = 34 + 21.
How is Fibonacci related to the golden ratio?
The ratio of consecutive terms approaches φ ≈ 1.618034 as n grows. It is already 1.618 to three decimals at F(10)/F(9) = 55/34, and F(n) ≈ φn ÷ √5 becomes a practical shortcut from about n = 10 onward.
What is the largest n supported?
The calculator accepts n up to 1476. Past that, Fibonacci numbers exceed the exact range of JavaScript floating-point integers, and the trailing digits would no longer be trustworthy.
Can I start from different values?
Yes. F(0) = 2, F(1) = 1 gives the Lucas sequence with L(10) = 123, and any other pair of seeds works the same way. The recurrence and the golden-ratio convergence are unchanged by the seeds.
Why is F(0) sometimes listed as 1?
Two indexing conventions exist. This calculator uses F(0) = 0, F(1) = 1, so F(10) = 55. References that start the sequence at 1 without an F(0) would call the same value the 11th term, which explains most off-by-one disagreements.
How fast does the sequence grow?
Each term is about 1.618 times the previous one. F(10) = 55 grows to F(20) = 6,765 and F(30) = 832,040, so ten extra indices multiply the value by roughly 123.
Is there a formula that skips the iteration?
Binet’s formula F(n) = (φn − (−φ)n) ÷ √5 gives the exact term in theory, but floating-point rounding corrupts it for large n. The iterative addition used here stays exact up to n = 1476.
What are Fibonacci retracement levels in trading?
Traders draw ratios of 23.6%, 38.2%, 61.8% and 100% between a price swing’s high and low to mark possible support or reversal zones. The percentages come from ratios of Fibonacci terms to their neighbors, such as 34/55 ≈ 61.8%.
Method and sources
- Fibonacci recurrence F(n) = F(n-1) + F(n-2).