Skip to content
UniKit

Fibonacci calculator

Compute the n-th Fibonacci number exactly with fast doubling (n up to 10000), plus the first n terms, the ratio versus the golden ratio, a Fibonacci-number test and the matching Lucas numbers.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Index nRange 0 ≤ n ≤ 10000, F(0) = 0, F(1) = 1
Term F(n)

Enter n to compute automatically

Golden ratio φ = 1.618033988749895…

Is it a Fibonacci number?

Enter an integer to test it

Test: one of 5x² ± 4 is a perfect square

Lucas numbers compared

Lucas numbers: L(0) = 2, L(1) = 1, L(n) = 2F(n+1) − F(n)

nF(n)L(n)
002
111
213
324
437
5511
6818
71329
82147
93476

What this tool does

  • Verify the n-th Fibonacci number when solving algorithm problems: in most languages F(79) already breaks double precision, while this returns exact BigInt values.
  • Watch the ratio of consecutive terms converge on the golden ratio: F(11)/F(10) is already 1.618181818181 with an error of 1.478e-4, which makes the convergence easy to explain.
  • Test whether an integer is a Fibonacci number (144 is, 145 is not) for data validation or sequence filtering.
  • Compare against the Lucas numbers: L(0) = 2, L(1) = 1, and L(n) = 2F(n+1) − F(n) shows how the two sequences are linked.

Example

Input

n = 10

Output

F(10) = 55; 2 digits; ratio F(11)/F(10) = 1.618181818181; error vs. golden ratio 1.478e-4; L(10) = 123

Indices start at 0 with F(0) = 0 and F(1) = 1; the ratio only exists for n ≥ 1 and is truncated to 12 decimal places.

Frequently asked questions

Is F(0) equal to 0 or 1?

Here F(0) = 0 and F(1) = 1 — the classic zero-based definition, giving 0, 1, 1, 2, 3, 5, 8 … Some textbooks start numbering at 1, so expect a one-index offset when comparing.

Why does my language get F(80) wrong?

F(79) already exceeds 2^53, and a double can only represent integers exactly up to 9007199254740992. This tool uses BigInt arithmetic plus fast doubling, which turns n sequential steps into O(log n) big multiplications, so even n = 10000 stays exact.

How is "is it a Fibonacci number?" decided?

With the standard necessary-and-sufficient test: if 5x² + 4 or 5x² − 4 is a perfect square, then x is a Fibonacci number. That is why 144 passes and 145 fails. Negative input is rejected, and integers longer than 1000 digits are refused.

Why is the ratio of consecutive terms not exactly the golden ratio?

F(n+1)/F(n) only reaches (1+√5)/2 as n goes to infinity, so any finite term carries an error. The tool truncates the ratio to 12 decimals and prints the error in scientific notation; the larger n is, the smaller the error.

Does it go online, and is my input uploaded?

No. Every sequence calculation runs locally in your browser with BigInt, the page sends no requests, and the number you type is never uploaded.

Keywords:fibonacci斐波那契golden ratio黄金比lucas卢卡斯数fast doubling数列

Related tools