Fibonacci Sequence Calculator

Fibonacci terms through BigInt, exact past F(79) where a JavaScript number stops being, with the golden ratio convergence decided exactly.

Enable JavaScript to customise; default output below.

Indexed from F(0) = 0, which is the mathematical convention. Some references start at F(1) = 1, which shifts everything by one.

Optional. Answers which term it is, or the nearest one above it.

Live preview fibonacci.txt
F(75) to F(86)
  F(75)                              2,111,485,077,978,050
  F(76)                              3,416,454,622,906,707
  F(77)                              5,527,939,700,884,757
  F(78)                              8,944,394,323,791,464
  F(79)                              14,472,334,024,676,221  ← past 2^53
  F(80)                              23,416,728,348,467,685  ← past 2^53
  F(81)                              37,889,062,373,143,906  ← past 2^53
  F(82)                              61,305,790,721,611,591  ← past 2^53
  F(83)                              99,194,853,094,755,497  ← past 2^53
  F(84)                              160,500,643,816,367,088  ← past 2^53
  F(85)                              259,695,496,911,122,585  ← past 2^53
  F(86)                              420,196,140,727,489,673  ← past 2^53

Sum of these terms                   1,096,671,323,743,195,224
Digits in the last term              18

The ratio between consecutive terms
  F(81)/F(80)                        1.618033988750  above
  F(82)/F(81)                        1.618033988750  below
  F(83)/F(82)                        1.618033988750  above
  F(84)/F(83)                        1.618033988750  below
  F(85)/F(84)                        1.618033988750  above
  F(86)/F(85)                        1.618033988750  below
  the golden ratio                   1.618033988750, which is (1 + √5) / 2

Is 6,765 a Fibonacci number
  answer                             yes, it is F(20)

Every term here comes from BigInt. A JavaScript number is exact only to
2^53, and F(79) is 14,472,334,024,676,221, which is already past it, so
a calculator using a plain number is wrong from that term onwards and
does not say so. Terms at or beyond it are marked above.

The ratio between consecutive terms converges on the golden ratio,
alternating above and below it. That is the real relationship between
the two, and by the twentieth term it agrees to seven decimal places.
The sequence is not "based on" the golden ratio; the ratio falls out of
it.

Indexing matters when comparing tools. This starts at F(0) = 0, which is
the mathematical convention. Plenty of references start at F(1) = 1,
which shifts every term by one and is the usual reason two calculators
appear to disagree.

The claim that Fibonacci numbers are everywhere in nature is mostly
overstated. Spiral phyllotaxis in sunflowers and pine cones is real and
has a mechanical explanation; nautilus shells are a logarithmic spiral
that is not the golden one; and the golden ratio in the Parthenon and in
Renaissance painting is largely read back into them by
nineteenth-century authors.

Story points in Fibonacci are used for a reason that has nothing to do
with mathematics: the gaps grow, so the scale refuses to express false
precision. The difference between 5 and 8 is a real judgement and the
difference between 21 and 22 is not, which is why the scale stops
offering it.

Binet's formula gives the nth term directly from powers of the golden
ratio, and it is a bad way to compute one: floating point rounding
breaks it in the seventies, at almost exactly the point where a plain
number does. Iteration with exact integers is both simpler and correct.

The sum of the first n terms is F(n+2) − 1, which is a good way to check
any implementation. Every Fibonacci identity of that kind is exact, so a
tool that gets one wrong by a digit is telling you it lost precision
somewhere.

Output is valid and updates as you type.

F(79) is 14,472,334,024,676,221. A JavaScript number will tell you it is 14,472,334,024,676,220, because a double is exact only to 2^53 and that term is past it.

So every Fibonacci calculator built on ordinary numbers is wrong from the seventy-ninth term onwards, and none of them says so. This one goes through BigInt, which is exact at any size, and marks the terms where the difference begins.

The other thing worth printing is the ratio between consecutive terms. It converges on the golden ratio, alternating above and below it, and by the twentieth term it agrees to seven decimal places. That is the actual relationship between the two: the ratio falls out of the sequence rather than the sequence being built from the ratio.

How to use

  1. Choose how many terms and where to start.
  2. Read the marked terms to see where a double would have gone wrong.
  3. Put a number in the last field to find out whether it is in the sequence.

Example

Twelve terms from F(75):

  F(78)                              8,944,394,323,791,464
  F(79)                              14,472,334,024,676,221  ← past 2^53
  F(80)                              23,416,728,348,467,685  ← past 2^53

The ratio between consecutive terms
  F(81)/F(80)                        1.618033988750  above
  F(82)/F(81)                        1.618033988750  below
  the golden ratio                   1.618033988750, which is (1 + √5) / 2

Is 6,765 a Fibonacci number
  answer                             yes, it is F(20)

The “above” and “below” markers are decided by integer arithmetic, not by comparing decimals: a truncated division would report “below” every time once the digits ran out, which would be wrong half the time.

Pitfalls

Indexing differs between references. This starts at F(0) = 0, the mathematical convention. Plenty of sources start at F(1) = 1, which shifts every term by one, and that is the usual reason two calculators appear to disagree.

Binet’s formula is a bad way to compute a term. It gives the nth term directly from powers of the golden ratio and it breaks in the seventies from floating-point rounding, at almost exactly the point a plain integer does. Iterating with exact integers is simpler and correct.

Fibonacci in nature is mostly overstated. Spiral phyllotaxis in sunflowers and pine cones is real and has a mechanical explanation. Nautilus shells are a logarithmic spiral and not the golden one, and the golden ratio in the Parthenon and in Renaissance painting was largely read back into them by nineteenth-century writers.

Story points use it for a non-mathematical reason. The gaps grow, so the scale refuses to express false precision: the difference between 5 and 8 is a real judgement and the difference between 21 and 22 is not. That is the whole argument for it, and it has nothing to do with spirals.

The identities are exact, so they make good tests. The sum of the first n terms is F(n+2) − 1, and Cassini’s identity says F(n−1)F(n+1) − F(n)² is ±1. Any implementation that gets one of those off by a digit has lost precision.

Negative indices exist. F(−n) = (−1)^(n+1)F(n), the “negafibonacci” numbers. They are not offered here because almost nobody wants them and their sign convention causes more confusion than it solves.

Compatibility

Everything runs in the browser: nothing is uploaded and nothing is stored.

BigInt is in every browser since 2018 and is limited only by memory. Terms up to F(1000), which has 209 digits, are available; the sequence is generated iteratively, so a thousand terms is a thousand additions.

The ratio is computed in BigInt and formatted by hand rather than going through a number, so the digits stay correct at any term. Whether a ratio is above the golden ratio is decided by comparing (2a − b)² against 5b², which is exact integer arithmetic, since a/b > (1+√5)/2 is the same statement.

The membership check generates terms until it reaches or passes the value, rather than using the 5n² ± 4 perfect-square test, because BigInt has no square root and an exact integer square root of a large number is more work than the iteration.

The test suite checks the sum identity, Cassini’s identity, the digit count at term 1000, and that F(79) differs from what a double reports.

Frequently asked questions

What is the 100th Fibonacci number?
354,224,848,179,261,915,075. Any tool that gives you a number ending in a different digit is using floating point, which is the point of this one.
Why does my calculator give a different term number?
Because it starts at F(1) = 1 rather than F(0) = 0. Both conventions are in use; check which one a reference uses before comparing.
Is the golden ratio really in the sequence?
The ratio of consecutive terms converges on it, exactly, and that is a theorem. The claims about it appearing in art, architecture and shells are a different matter and mostly do not survive measurement.
What is Fibonacci used for in programming?
Mostly as a teaching example for recursion and memoisation, where the naive recursive version is famously exponential. In production, the sequence turns up in Fibonacci heaps and in some retry backoff schemes.
Can I use it for design proportions?
You can, and a type scale built on 1.618 is a reasonable choice among several. The golden ratio calculator and the type scale generator on this site both do that directly, and neither claims the ratio is objectively more beautiful.
Weekly drops

New tools, when there are new tools

One email when something worth using ships. No schedule to fill, so no filler.

Your address goes nowhere else, and one click unsubscribes.