Fibonacci Sequence Calculator

Enter a term index and this calculator returns that Fibonacci number, the term immediately after it, the running sum of every term up to it, and the ratio of consecutive terms that closes in on the golden ratio φ = 1.6180339887. It builds the sequence by the recurrence rather than by a formula, so the integers it reports are exact, and it evaluates Binet's closed form alongside them so you can see the two agree. Change the two starting terms and you get a generalised Fibonacci sequence — set them to 2 and 1 for the Lucas numbers.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Term index nWhich term you want, counting the first starting term as n = 1. The ceiling of 78 is where a double-precision float stops holding Fibonacci numbers exactly.20
First term G₁Leave at 1 for the standard Fibonacci sequence; enter 2 here and 1 below for the Lucas numbers.1
Second term G₂Leave at 1 for the standard Fibonacci sequence. Every later term is the sum of the two before it whatever you put here.1

It returns

  • Term Gₙ — Built by repeated addition from your two starting terms, so it is the exact integer.
  • Next term Gₙ₊₁
  • Sum of the first n terms — Equal to Gₙ₊₂ − G₂, which for the standard sequence is Fₙ₊₂ − 1.
  • Ratio Gₙ₊₁ ÷ Gₙ — Undefined when Gₙ is zero, which is why this can read as a dash for some starting pairs.
  • Binet's closed form at n — (φⁿ − ψⁿ) ÷ √5 for the standard sequence. It equals the term above only when the starting terms are 1 and 1.

The formula

Fn=φnψn5
k=1nFk=Fn+21
k=1nGk=Gn+2G2

In plain text: Fₙ = Fₙ₋₁ + Fₙ₋₂, with F₁ = F₂ = 1; Binet: Fₙ = (φⁿ − ψⁿ) ÷ √5

  • FₙThe nth Fibonacci number, counting F₁ = 1 as the first (integer)
  • nTerm index, a positive whole number (—)
  • φGolden ratio, (1 + √5) ÷ 2 = 1.6180339887 (—)
  • ψConjugate root, (1 − √5) ÷ 2 = −0.6180339887 (—)

φ and ψ are the two roots of x² = x + 1, the characteristic equation of the recurrence. Because |ψ| < 1, the ψⁿ term shrinks towards zero and Fₙ ends up within half a unit of φⁿ ÷ √5 for every n ≥ 1.

Updated Category Sequences, Series & Combinatorics Verified against published test cases Reading time 12 min

What the Fibonacci sequence is and why the ratio matters

The Fibonacci sequence is the list of numbers you get when you start with 1, 1 and make every later number the sum of the two before it: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55. That single rule — Fn = Fn−1 + Fn−2 — is the whole definition. Everything else about the sequence is a consequence of it.

The consequence people care about is the ratio. Divide each term by the one before it and you get 1, 2, 1.5, 1.6667, 1.6, 1.625, 1.6154, 1.6190 … The values bounce either side of a limit and close in on it fast. That limit is the golden ratio φ = 1.6180339887, and it is not a coincidence: if the ratio settles down to some value x, then dividing the recurrence through by Fn−1 gives x = 1 + 1/x, so x² = x + 1. Solve that quadratic with the quadratic formula and the positive root is exactly (1 + √5) ÷ 2. The golden ratio calculator works the same number from the geometric definition.

This matters outside recreational mathematics. Fibonacci numbers are the worst case for the Euclidean algorithm, so they bound how many division steps a greatest common factor computation can take. They index the Fibonacci heap and the Fibonacci search technique. And because the sequence grows geometrically at rate φ, it is a standard first example when you want to show that a linear recurrence has exponential behaviour without ever writing an exponential.

The recurrence, Binet's closed form, and the sum identity

You have three ways to reach the same number, and this calculator uses all three so they can check one another.

The recurrence. Add the previous two terms. This is exact — every intermediate value is a whole number — and it costs n additions. That is what produces the headline term here.

Binet's closed form. Fn = (φnψn) ÷ √5, where ψ = (1 − √5) ÷ 2 = −0.6180339887. The two symbols are the roots of the characteristic equation x² = x + 1, and any sequence of the form n + n satisfies the recurrence for any constants A and B. Picking A = 1/√5 and B = −1/√5 is the choice that makes the first two terms come out as 1 and 1, and that pins down the sequence completely. Because |ψ| is less than 1, ψn never exceeds 0.62 in size and shrinks quickly, which is why Fn is always the nearest integer to φn ÷ √5.

The sum identity. F1 + … + Fn = Fn+2 − 1. Proof in one line: rewrite each Fk as Fk+2Fk+1; the sum telescopes to Fn+2F2, and F2 = 1. Change the starting terms and the same telescoping gives Gn+2G2, which is why the identity still works when you enter 2 and 1 for the Lucas numbers.

Worked example: the 12th Fibonacci number, three ways

Set the term index to 12 and leave both starting terms at 1.

  1. Build the list. 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144. The twelfth entry is 144.
  2. Check the last step. F12 = F11 + F10 = 89 + 55 = 144.
  3. Sum by hand. 1 + 1 + 2 + 3 + 5 + 8 + 13 + 21 + 34 + 55 + 89 + 144, accumulating as 2, 4, 7, 12, 20, 33, 54, 88, 143, 232, 376.
  4. Sum by the identity. F14 − 1 = 377 − 1 = 376. The two agree.
  5. Ratio. F13 ÷ F12 = 233 ÷ 144 = 1.6180556. That sits 0.0000216 above φ = 1.6180340.
  6. Binet. A convenient identity gives the powers exactly: φn = (Ln + Fn√5) ÷ 2 with L12 = 322, so φ12 = (322 + 144 × 2.2360680) ÷ 2 = (322 + 321.9937888) ÷ 2 = 321.9968944. Likewise ψ12 = (322 − 321.9937888) ÷ 2 = 0.0031056.
  7. Finish Binet. 321.9968944 − 0.0031056 = 321.9937888, and 321.9937888 ÷ 2.2360680 = 144.000000.

All three routes land on 144, which is the point of running them together: the recurrence is exact but slow to write out, Binet is fast but floating-point, and the sum identity is a cross-check on both.

How to read the ratio column

Look at the ratio column and you will see it straddle φ rather than approach from one side. For the standard sequence the ratio Fn+1 ÷ Fn lands below φ when n is odd and above it when n is even: 1.000 at n = 1, 2.000 at n = 2, 1.500 at n = 3, 1.6667 at n = 4. That alternation comes straight from Binet: the ψn term flips sign with every step, so the error it introduces flips too.

The size of the error falls by a factor of about φ² = 2.618 per term, which is why you gain roughly two decimal places every five terms. By n = 15 the ratio 987 ÷ 610 = 1.6180328 matches φ to five decimal places; by n = 20 the ratio 10,946 ÷ 6,765 = 1.6180340 matches it to seven. If you need φ itself rather than an approximation, take the square root of 5, add 1 and halve.

The growth rate is the other thing worth reading. Each term is about 1.618 times the last, so the sequence behaves like a geometric sequence with common ratio φ once the early terms are past. That gives a useful shortcut: the number of Fibonacci terms below some bound M is roughly log(M√5) ÷ log φ, so the count reaches 30.4 at a million and 44.7 at a billion. This calculator confirms both crossings: F30 = 832,040 is the last term below a million and F45 = 1,134,903,170 is the first above a billion.

Fibonacci numbers, running sums and consecutive ratios

The first twenty Fibonacci numbers with the cumulative sum and the ratio to the previous term. Ratios are shown to six decimal places; φ = 1.618034 to the same precision.
nFnΣF1..FnFn ÷ Fn−1
111
2121.000000
3242.000000
4371.500000
55121.666667
68201.600000
713331.625000
821541.615385
934881.619048
10551431.617647
11892321.618182
121443761.617978
132336091.618056
143779861.618026
156101,5961.618037
169872,5831.618033
171,5974,1801.618034
182,5846,7641.618034
194,18110,9451.618034
206,76517,7101.618034

Every cumulative entry equals Fₙ₊₂ − 1: at n = 20 that is 17,711 − 1 = 17,710. Note that the ratio column here is Fₙ ÷ Fₙ₋₁, one index earlier than the Fₙ₊₁ ÷ Fₙ output tile, so row 12 reads 1.617978 while the tile at n = 12 reads 1.618056.

Why the term index stops at 78

A JavaScript number is an IEEE 754 double, which represents every integer exactly up to 253 = 9,007,199,254,740,992 and only some integers above it. F78 = 8,944,394,323,791,464 is under that ceiling; F79 = 14,472,334,024,676,221 is over it, and would come back with its last digits silently wrong. The input maximum is set at 78 so that every integer this page reports is the true one.

If you enter starting terms much larger than 1, the terms grow proportionally faster and can cross the same ceiling well before n = 78. The calculator raises a warning when any headline figure exceeds it.

Pitfalls and assumptions

  • Indexing conventions differ. This calculator uses F1 = 1, F2 = 1. Many textbooks and most programming references start at F0 = 0, F1 = 1, which shifts every index by one. Before you compare a value against a published table, check which convention it uses.
  • Binet is not exact in floating point. The closed form is exact in algebra but φn is not representable, so the computed value drifts from the integer as n grows. Rounding to the nearest integer recovers the right answer well beyond the range this page allows, but the raw closed-form figure is not the value to quote.
  • Recursion without memoisation is exponentially slow. The naive recursive definition calls itself twice per term and evaluates Fn in roughly Fn calls. Use iteration or memoisation; that is why this calculator loops.
  • The ratio is undefined wherever a term is zero. The standard sequence never hits zero after the start, but generalised starting pairs such as 1 and 0, or 3 and −3, produce a zero term and a blank ratio at that point.
  • Fibonacci-like does not mean Fibonacci. A sequence that merely grows at roughly 1.618 per step is a geometric sequence, not a Fibonacci one. The defining property is the additive recurrence, not the growth rate.

Lucas numbers, generalised sequences and when to use a different tool

Set the starting terms to 2 and 1 and you get the Lucas numbers: 2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123. They obey the same recurrence and are tied to the Fibonacci numbers by Ln = Fn−1 + Fn+1 and by φn = (Ln + Fn√5) ÷ 2, the identity used in the worked example above. Their consecutive ratio converges to the same φ, because φ is a property of the recurrence rather than of the starting values.

Any starting pair works. The general solution of the recurrence is n + n, and the two starting terms fix A and B. Since |ψ| < 1, the φ part dominates for every starting pair except the single degenerate line where A = 0, which needs G2 ÷ G1 to be exactly the irrational number ψ and so cannot be reached with the whole-number inputs here.

Reach for a different tool when the pattern is not additive. A sequence with a constant difference is an arithmetic sequence; one with a constant multiplier is a geometric sequence. If you are counting arrangements rather than continuing a pattern, the combination calculator or the factorial calculator is the right page — though the two subjects meet in a pretty identity: summing the shallow diagonals of Pascal's triangle, the same triangle behind binomial expansion, reproduces the Fibonacci numbers exactly.

Key terms

Recurrence relation
A rule that defines each term of a sequence using earlier terms. The Fibonacci recurrence is second-order and linear: it looks back two terms and combines them with constant coefficients.
Characteristic equation
The polynomial you get by substituting xn into a linear recurrence. For Fibonacci it is x² = x + 1, whose roots φ and ψ drive the closed form.
Closed form
A formula that gives the nth term directly from n, with no loop and no reference to earlier terms. Binet's formula is the closed form for Fibonacci.
Golden ratio (&phi;)
(1 + √5) ÷ 2 = 1.6180339887. The unique positive number that is one greater than its own reciprocal, and the limit of the Fibonacci ratio.
Generalised Fibonacci sequence
Any sequence obeying Gn = Gn−1 + Gn−2 with arbitrary starting terms. The Lucas numbers are the best-known example after Fibonacci itself.

Frequently asked questions

What is the 100th Fibonacci number?

354,224,848,179,261,915,075 — but this calculator stops at n = 78 and will not produce it. The reason is that ordinary double-precision arithmetic only stores integers exactly up to 9,007,199,254,740,992, and F79 is already past that. Returning a 21-digit figure whose last six digits were wrong would be worse than declining. For terms beyond 78 you need arbitrary-precision integers, which every major language offers as a big-integer type.

Does the Fibonacci sequence start with 0 or with 1?

Both conventions are in use and both are correct within their own numbering. This page uses F1 = 1, F2 = 1, which is the classical convention and the one under which the sum identity reads Fn+2 − 1. Computer science and the OEIS more often use F0 = 0, F1 = 1, which makes Binet's formula and the matrix power form come out cleanly. If you want the F0 = 0 numbering, subtract one from your index before entering it here.

Why does the ratio of consecutive terms give the golden ratio?

Because the ratio, if it settles at all, has to satisfy x = 1 + 1/x. Divide the recurrence Fn = Fn−1 + Fn−2 through by Fn−1, and the left side is the current ratio while the right side is 1 plus the reciprocal of the previous ratio. Rearranged, x² − x − 1 = 0, whose positive root is (1 + √5) ÷ 2. The argument does not depend on the starting terms, which is why Lucas numbers converge to the same limit.

Is Binet's formula faster than adding the terms up?

Not usefully, for the range this page covers. Binet needs two exponentiations and a division, while the loop needs n additions, and for n under 80 the loop is already sub-microsecond. Binet's real value is analytical: it proves the growth rate is exactly φ per step and gives you a direct estimate of how many terms fit under any bound. If you genuinely need one very large term quickly, fast matrix exponentiation on [[1,1],[1,0]] beats both, at O(log n) big-integer multiplications.

What does the sum of the first n Fibonacci numbers equal?

Fn+2 − 1. Summing the first ten terms gives F12 − 1 = 144 − 1 = 143, and adding 1 + 1 + 2 + 3 + 5 + 8 + 13 + 21 + 34 + 55 by hand confirms it. The proof rewrites each Fk as Fk+2 − Fk+1 so that the sum telescopes. With non-standard starting terms the identity becomes Gn+2 − G2, which this calculator uses in its steps.

What happens if I enter negative starting terms?

The sequence runs perfectly well and the consecutive ratio still converges to φ, though the terms themselves may be negative. Enter 1 and −1, for instance, and you get 1, −1, 0, −1, −1, −2, −3, −5, −8 — the Fibonacci numbers with a sign attached, after a short transient. The ratio reads as a dash at the term following the zero, because dividing by zero has no answer.

How many Fibonacci numbers are there below one million?

Thirty, under this page's F1 = 1 numbering: F30 = 832,040 is the last below a million and F31 = 1,346,269 is the first above. You can estimate this without the list, because the terms grow like φn ÷ √5: solving φn ÷ √5 = 1,000,000 gives n ≈ 30.0. The same estimate puts the crossing of a billion at n ≈ 44.7, and F44 = 701,408,733 with F45 = 1,134,903,170 confirms that the first term above a billion is the 45th.

Are Lucas numbers a different sequence or the same one?

They obey the same recurrence but start 2, 1 instead of 1, 1, so they are a different sequence with the same growth law. Enter 2 and 1 in the starting-term fields to generate them: 2, 1, 3, 4, 7, 11, 18, 29, 47, 76. They interlock with Fibonacci through Ln = Fn−1 + Fn+1, and the pair together gives the exact power identity φn = (Ln + Fn√5) ÷ 2.

Why does my recursive Fibonacci program take so long?

Because the plain recursive definition recomputes the same terms over and over. Calling fib(n) spawns fib(n−1) and fib(n−2), each of which spawns two more, and the total number of calls is exactly 2Fn − 1, which grows like 1.618n. At n = 40 that is 2 × 102,334,155 − 1 = 204,668,309 calls. Store results as you go, or replace the recursion with the two-variable loop this calculator uses, and the cost drops to n additions.

References

  • Concrete Mathematics: A Foundation for Computer Science, 2nd ed. (Chapter 6, Fibonacci numbers) — Ronald Graham, Donald Knuth and Oren Patashnik, Addison-Wesley
  • The Art of Computer Programming, Volume 1: Fundamental Algorithms, 3rd ed. (Section 1.2.8) — Donald E. Knuth, Addison-Wesley
  • The On-Line Encyclopedia of Integer Sequences, A000045 (Fibonacci) and A000032 (Lucas)OEIS Foundation
  • IEEE Standard for Floating-Point Arithmetic, IEEE 754-2019 — IEEE