🌀 Fibonacci Generator

🔧 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

Generated {{ sequenceResult.count }} values starting at F({{ sequenceResult.start }}). [some values exceed Number.MAX_SAFE_INTEGER]
{{ sequenceValuesText }}

📤 Result

F({{ nthResult.n }}) — {{ nthResult.digits }} digit{{ nthResult.digits === 1 ? '' : 's' }} [exceeds Number.MAX_SAFE_INTEGER]
{{ nthResult.value }}

📤 Result

{{ isFibResult.n }} IS Fibonacci — F({{ isFibResult.index }}) {{ isFibResult.n }} is NOT a Fibonacci number

Nearest Fibonacci neighbours

Lower: F({{ isFibResult.nearest.lower.index }}) = {{ isFibResult.nearest.lower.value }}
Lower: none
Upper: F({{ isFibResult.nearest.upper.index }}) = {{ isFibResult.nearest.upper.value }}

📤 Range

Found {{ rangeResult.count }} Fibonacci value{{ rangeResult.count === 1 ? '' : 's' }} in [{{ rangeResult.from }}, {{ rangeResult.to }}]
{{ 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 2000 consecutive Fibonacci numbers, optionally starting from a non-zero index such as F(100).
  • nth term: calculate the exact value of F(n) for 0 ≤ n ≤ 50000. F(50000) has 10450 decimal 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 through F(958).

How the exact math works

  • Iterative recurrence: sequence and range output walk forward with two BigInts, (prev, curr), applying next = 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)) and F(2k+1) = F(k)2 + F(k+1)2. Each recursive step halves the index, so the number of levels grows with log2(n) rather than n.
  • Perfect-square membership test: a positive integer n is Fibonacci if and only if 5n2 + 4 or 5n2 − 4 is 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) returns 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89.
  • sequence(10, 10) starts at F(10) and returns 55, 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 index 7; isFibonacci(14) is false, bracketed by F(7) = 13 and F(8) = 21.
  • range(10, 100) returns 13, 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.
  • 1 appears twice in the mathematical sequence, as F(1) and F(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

API Usage Example:

POST /api/tools/math/fibonacci-generator
Content-Type: application/json

{
    "operation": "sequence",
    "count": 20
}
Ready