🔧 Operation
📝 Sequence parameters
Returns the first count Fibonacci numbers starting at F(start). All values are returned as decimal strings (some exceed Number.MAX_SAFE_INTEGER).
📝 Index n
Integer between 0 and 50,000. Uses fast doubling — nth(50000) resolves in under one second.
📝 Number to test
Pass arbitrarily-large positive integers as a digit string. Uses the 5n2±4 perfect-square identity for an exact decision.
📝 Range
Inclusive bounds. Upper limit capped at 10200 (about F(960)).
📤 Sequence
{{ sequenceValuesText }}
📤 Result
{{ nthResult.value }}
📤 Result
Nearest Fibonacci neighbours
📤 Range
{{ rangeValuesText }}
Result will appear here as you type.
ℹ️ About Fibonacci Generator
What is the Fibonacci sequence?
The Fibonacci sequence is the integer sequence defined by
F(0) = 0, F(1) = 1, and
F(n) = F(n−1) + F(n−2) for n ≥ 2.
Its first values are
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, ….
The canonical sequence entry is
OEIS A000045,
with an exact indexed value file at
b000045.txt.
Use this Fibonacci generator when you need exact decimal values, not floating-point approximations. The
calculator uses arbitrary-precision ECMAScript BigInt
arithmetic internally and returns decimal strings so values larger than Number.MAX_SAFE_INTEGER
stay intact in browser output and API responses.
What this tool calculates
- Sequence: generate up to
2000consecutive Fibonacci numbers, optionally starting from a non-zero index such asF(100). - nth term: calculate the exact value of
F(n)for0 ≤ n ≤ 50000.F(50000)has10450decimal digits. - Membership test: check whether a non-negative integer is a Fibonacci number and return its index when it is. If it is not, the tool reports the nearest lower and upper Fibonacci numbers.
- Range: list every Fibonacci number in an inclusive numeric interval. The upper bound is capped at
10200, which includes terms throughF(958).
How the exact math works
-
Iterative recurrence: sequence and range output walk forward with two BigInts,
(prev, curr), applyingnext = prev + curr. Non-zero sequence starts are seeded from the exact pair(F(start), F(start+1)). -
Fast doubling: nth-term calculation uses the identities
F(2k) = F(k) · (2·F(k+1) − F(k))andF(2k+1) = F(k)2 + F(k+1)2. Each recursive step halves the index, so the number of levels grows withlog2(n)rather thann. -
Perfect-square membership test: a positive integer
nis Fibonacci if and only if5n2 + 4or5n2 − 4is a square. This identity is stated in Ira Gessel's 1972 Fibonacci Quarterly problem Fibonacci is a Square. The tool uses a BigInt integer-square-root routine so the check never rounds through a floating-point number.
Golden ratio connection
As n → ∞, the ratio F(n+1) / F(n) approaches the golden ratio
Φ = (1 + √5) / 2 ≈ 1.6180339887…, catalogued as
OEIS A001622. Binet's formula
expresses F(n) with powers of Φ, but evaluating that formula with ordinary
floating-point numbers eventually introduces rounding errors. This tool uses integer recurrences instead, so
nth(100), nth(500), and nth(50000) are exact decimal integers.
Practical use cases
- Programming exercises: compare naive recursion, memoization, bottom-up iteration, matrix exponentiation, and fast doubling with the same expected outputs.
- Big integer test vectors: generate exact decimal strings for unit tests, JSON API tests, serialization checks, and arbitrary-precision math libraries.
- Number theory checks: explore Fibonacci membership, neighboring terms, perfect-square identities, and recurrence behavior over large values.
- Teaching recurrence relations: show how two seed values define an infinite sequence and why dynamic programming avoids repeated work.
- Design and rhythm references: inspect Fibonacci ratios and golden-ratio convergence without treating rounded approximations as exact integers.
Worked examples
sequence(12)returns0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89.sequence(10, 10)starts atF(10)and returns55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.nth(100)→354224848179261915075(21 digits).nth(500)returns a 105-digit value, cross-checkable against OEIS A000045 b-file.isFibonacci(13)is true at index7;isFibonacci(14)is false, bracketed byF(7) = 13andF(8) = 21.range(10, 100)returns13, 21, 34, 55, 89.
Limitations and input rules
- Inputs must be non-negative base-10 integers. Decimal fractions, scientific notation, separators, and negative-index Fibonacci variants are not accepted.
1appears twice in the mathematical sequence, asF(1)andF(2). The membership result reports the first matching index.- The range mode is bounded so very large intervals cannot generate unbounded responses. Use nth-term mode when you need a single large value.
- This tool calculates Fibonacci numbers only. Lucas numbers, generalized seeds, Pisano periods, and modular Fibonacci sequences are related topics but not part of this page.
Source references
- OEIS A000045 and b000045.txt: canonical Fibonacci sequence values and indexed test data.
- Ira Gessel, Fibonacci is a Square, Fibonacci Quarterly 10(4), 1972: source for the
5n2 ± 4square test. - OEIS A001622: decimal expansion and references for the golden ratio
Φ. - Wolfram MathWorld: Fibonacci Number: compact reference for Binet's formula and common Fibonacci identities.
- ECMAScript BigInt type: official numeric type used for exact large-integer arithmetic in the browser logic.
API Usage Example:
POST /api/tools/math/fibonacci-generator
Content-Type: application/json
{
"operation": "sequence",
"count": 20
}