Fibonacci Calculator | F(n), Sequence & Check
Find any Fibonacci number F(n) with exact BigInt arithmetic up to F(10000), generate sequences with golden ratio convergence, and check whether any integer is a Fibonacci number using the algebraic 5n²±4 perfect-square test.
Exact BigInt for any n ≤ 10,000. F(1000) has 209 digits.
Press Enter to calculate · Esc to reset
What Is the Fibonacci Calculator | F(n), Sequence & Check?
The Fibonacci sequence is defined by the simplest possible second-order recurrence: each number is the sum of the two before it. Starting from 0 and 1, the sequence grows: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, … Despite its elementary definition, the Fibonacci sequence appears in an astonishing range of mathematical, natural, and computational contexts.
Binet's formula F(n) = (φⁿ − ψⁿ) / √5 gives a closed-form expression for any Fibonacci number without computing the sequence iteratively. Because |ψ| < 1, the ψⁿ term quickly becomes negligible: for n ≥ 1, F(n) = round(φⁿ / √5). This connects Fibonacci numbers directly to the golden ratio and explains why F(n+1)/F(n) converges to φ as n grows, which you can watch happen in the sequence generator mode.
This calculator uses JavaScript BigInt for all computation, unlike floating-point arithmetic, BigInt produces exact integer results regardless of magnitude. F(1000) (209 digits), F(5000) (1045 digits), and even F(10,000) are computed exactly, with no rounding error.
The Fibonacci test mode uses the algebraic characterisation: a positive integer n is a Fibonacci number if and only if at least one of 5n² + 4 or 5n² − 4 is a perfect square. This test works in O(log n) time with BigInt integer square roots, far faster than generating the entire sequence up to n.
Formula
| Symbol | Name | Description |
|---|---|---|
| F(n) | nth Fibonacci number | The term at index n (0-indexed: F(0)=0, F(1)=1) |
| φ | Golden ratio | (1+√5)/2 ≈ 1.6180339887…, limit of F(n+1)/F(n) |
| ψ | Conjugate golden ratio | (1−√5)/2 ≈ −0.618…, |ψ| < 1 so ψⁿ vanishes as n grows |
| √5 | Square root of 5 | ≈ 2.2360679…, normalisation constant in Binet's formula |
| L(n) | Lucas numbers | L(0)=2, L(1)=1, L(n)=L(n−1)+L(n−2); satisfy L(n) = F(n−1)+F(n+1) |
How to Use
- 1Select a mode: Choose "F(n)" to find the nth Fibonacci number, "Sequence" to generate a range of terms with their ratios, or "Check" to test whether a given number is Fibonacci.
- 2Load a preset or enter your value: In F(n) mode, click any preset (n = 10, 20, 50, 100, 500, 1000) to auto-fill. In Check mode, try the sample numbers to see the algebraic test in action.
- 3Press Calculate or Enter: Click "Calculate" or press Enter in any input. Results are computed instantly using exact BigInt arithmetic.
- 4Read the F(n) result: The primary card shows the exact Fibonacci number (truncated with start + end if > 60 digits), scientific notation, and digit count. The ratio F(n)/F(n−1) is shown to 10 decimal places alongside φ = 1.6180339887…
- 5Check nearby terms: The "Context" table shows F(n−3) through F(n+2), with the requested term highlighted. This makes it easy to see the additive pattern.
- 6Use the sequence generator: Enter a start index and count (up to 50 terms). The table shows index, exact value, and the ratio to the previous term, watch the ratio converge to φ as n increases.
- 7Verify a Fibonacci number: In Check mode, enter any positive integer. The calculator applies the 5n²±4 perfect-square test and, if it is Fibonacci, shows which index F(n) it is. A button then navigates directly to full detail.
- 8Copy the exact value: In F(n) mode, click "Copy F(n)" to copy the full untruncated integer string to your clipboard, useful for pasting into code, proofs, or other calculators.
Example Calculation
Example 1: F(12) = 144, a notable Fibonacci number
F(12) = 144 is the only Fibonacci number (other than 0 and 1) that is a perfect square.
Example 2: Is 1000 a Fibonacci number?
Use the algebraic test: compute 5 × 1000² ± 4 and check for perfect squares.
Example 3: F(1000), a large Fibonacci number
F(1000) has 209 digits. This calculator computes it exactly using BigInt arithmetic.
Understanding Fibonacci | F(n), Sequence & Check
The Golden Ratio Connection
The ratio of consecutive Fibonacci numbers converges to the golden ratio φ = (1 + √5)/2 ≈ 1.618. This is not a coincidence, it follows directly from Binet's formula and the fact that |ψ| = 0.618 < 1, causing the ψⁿ term to vanish. By the 20th term, the ratio already matches φ to 5 decimal places:
Fibonacci Numbers in Nature
- ›Phyllotaxis (plant spirals): The number of clockwise and counterclockwise spirals on a sunflower head, pine cone, or pineapple are always consecutive Fibonacci numbers, typically 34 and 55, or 55 and 89. This packing maximises seed density.
- ›Flower petals: Most flowers have a Fibonacci number of petals, lilies (3), buttercups (5), delphiniums (8), corn marigolds (13), asters (21). Natural selection appears to favour Fibonacci petal counts through the same phyllotaxis mechanism.
- ›Tree branching: Idealised tree branch models produce Fibonacci counts at each level, mirroring the Fibonacci recurrence.
- ›Spiral shells: The Nautilus shell growth approximates a golden spiral (growth factor φ per quarter turn), though the shell is a logarithmic spiral, the Fibonacci spiral is a discrete approximation.
Fibonacci Numbers in Mathematics & Computation
- ›Euclidean algorithm: The worst case for the Euclidean GCD algorithm occurs when inputs are consecutive Fibonacci numbers. F(n) and F(n+1) require exactly n steps, proving the algorithm's O(log min(a,b)) time complexity.
- ›Pascal's triangle: The sums of diagonal elements in Pascal's triangle produce Fibonacci numbers: F(n) = C(n,0) + C(n−1,1) + C(n−2,2) + … This connects Fibonacci numbers directly to combinatorics.
- ›Fibonacci search: An alternative to binary search that divides arrays at Fibonacci-number positions, useful when division is expensive but addition is cheap (e.g., disk-based search).
- ›Zeckendorf's theorem: Every positive integer has a unique representation as a sum of non-consecutive Fibonacci numbers. For example, 100 = 89 + 8 + 3 = F(11) + F(6) + F(4).
Fibonacci Reference Table
| n | F(n) | Digits |
|---|---|---|
| 0 | 0 | 1 |
| 5 | 5 | 1 |
| 10 | 55 | 2 |
| 20 | 6,765 | 4 |
| 30 | 832,040 | 6 |
| 50 | 12,586,269,025 | 11 |
| 100 | 354,224,848,179,261,915,075 | 21 |
| 200 | ≈ 2.8025 × 10⁴¹ | 42 |
| 500 | ≈ 1.3942 × 10¹⁰⁴ | 105 |
| 1000 | ≈ 4.3467 × 10²⁰⁸ | 209 |
| 5000 | ≈ 10¹⁰⁴⁴ | 1,045 |
Identities & Properties
- ›Cassini's identity: F(n+1)·F(n−1) − F(n)² = (−1)ⁿ, the determinant of the 2×2 matrix [[F(n+1), F(n)], [F(n), F(n−1)]] equals ±1.
- ›Doubling formulas (fast computation): F(2n) = F(n)(2F(n+1) − F(n)) and F(2n+1) = F(n)² + F(n+1)². This enables O(log n) computation, far faster than iteration for very large n.
- ›Sums: F(0) + F(1) + … + F(n) = F(n+2) − 1. The sum of the first n+1 Fibonacci numbers equals F(n+2) minus one.
- ›GCD property: gcd(F(m), F(n)) = F(gcd(m, n)), Fibonacci numbers respect the same GCD structure as their indices.
Frequently Asked Questions
What are the Fibonacci numbers and how are they defined?
The Fibonacci sequence is defined by the recurrence F(n) = F(n−1) + F(n−2) with seed values F(0) = 0 and F(1) = 1.
Each term is the sum of the two before it:
- • 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, …
- • F(10) = 55, F(20) = 6,765, F(50) = 12,586,269,025
The sequence was described by Leonardo of Pisa (nicknamed "Fibonacci") in 1202, in a problem about rabbit population growth, though the sequence was known in Indian mathematics centuries earlier.
What is the golden ratio and how does it relate to Fibonacci numbers?
The golden ratio φ = (1 + √5)/2 ≈ 1.6180339887… is the limit of the ratio F(n+1)/F(n) as n grows.
- • Why it happens: Binet's formula F(n) = (φⁿ − ψⁿ)/√5 shows both φ and its conjugate ψ = (1−√5)/2 ≈ −0.618 appear. Since |ψ| < 1, ψⁿ shrinks to zero, leaving F(n) ≈ φⁿ/√5.
- • F(n+1)/F(n) → φ: Dividing both sides of F(n) ≈ φⁿ/√5 by F(n−1) ≈ φⁿ⁻¹/√5 gives the ratio ≈ φ.
- • Convergence speed: By F(10), the ratio matches φ to 4 decimal places. By F(20), to 8 decimal places.
Use the sequence generator mode to watch the ratio column converge in real time.
How can I tell if a number is a Fibonacci number?
There is an elegant algebraic test: a positive integer n is a Fibonacci number if and only if 5n² + 4 or 5n² − 4 is a perfect square.
- • Example, is 144 Fibonacci? 5 × 144² + 4 = 103,684 = 322² ✓ → Yes, F(12) = 144.
- • Example, is 100 Fibonacci? 5 × 100² + 4 = 50,004 (not a perfect square); 5 × 100² − 4 = 49,996 (not a perfect square) → No.
The "Check" mode in this calculator applies this test using BigInt integer square roots, so it works for numbers with thousands of digits, no need to generate the entire sequence.
What is Binet's formula and when should I use it?
Binet's formula gives a closed-form expression for F(n):
F(n) = (φⁿ − ψⁿ) / √5 where φ = (1+√5)/2, ψ = (1−√5)/2
- • Practical shortcut: For n ≥ 1, F(n) = round(φⁿ / √5), since |ψⁿ| < 0.5 for n ≥ 1.
- • When to use it: Great for an approximation, or for proving properties algebraically. But floating-point errors accumulate for large n, the iterative BigInt approach in this calculator is exact for any n.
- • Digit count: log₁₀(F(n)) ≈ n × log₁₀(φ) − ½ × log₁₀(5), so each 5 terms adds roughly 1 digit.
Why do Fibonacci numbers appear in nature?
The appearance of Fibonacci numbers in plant structures is primarily explained by phyllotaxis, the way plant cells grow in spirals driven by local interactions at the meristem (growth tip).
- • Each new leaf, seed, or petal tends to form at the "most irrational" angle from the previous one, roughly 137.5° (the golden angle = 360°/φ²). This angle maximises packing density.
- • When you count the number of left and right spirals in a sunflower, pine cone, or pineapple, you always find consecutive Fibonacci numbers (e.g., 34 and 55, or 55 and 89).
- • This is not mystical design, it's a consequence of optimization: the Fibonacci angle produces the densest packing of seeds or leaves with minimum overlap.
It is worth noting that not every natural spiral follows this pattern exactly, biology introduces variation. But the tendency is remarkably robust across many species.
How large can Fibonacci numbers get, and how does this calculator handle them?
Fibonacci numbers grow exponentially, roughly multiplying by φ ≈ 1.618 each step. This calculator uses JavaScript BigInt for exact integer arithmetic with no upper digit limit.
- • F(100) ≈ 3.54 × 10²⁰ (21 digits)
- • F(1000) ≈ 4.35 × 10²⁰⁸ (209 digits)
- • F(5000) ≈ 10¹⁰⁴⁴ (1,045 digits)
- • F(10,000) ≈ 10²⁰⁸⁷ (2,090 digits), computed in under a second
Standard JavaScript floating-point numbers lose precision after about F(78) (≈ 8.9 × 10¹⁵). This calculator computes exactly up to n = 10,000 using BigInt, displaying the full number or a truncated preview with the full value copyable to clipboard.
What is the relationship between Fibonacci numbers and the Pascal's triangle?
If you sum along shallow diagonals in Pascal's triangle, you get Fibonacci numbers:
- • F(n) = C(n,0) + C(n−1,1) + C(n−2,2) + … (sum of binomial coefficients along a diagonal)
- • F(1) = C(1,0) = 1
- • F(4) = C(4,0) + C(3,1) + C(2,2) = 1 + 3 + 1 = 5 ✓
- • F(6) = C(6,0) + C(5,1) + C(4,2) + C(3,3) = 1 + 5 + 6 + 1 = 13 ✓
This connection shows that Fibonacci numbers count the number of ways to tile a 1×n board with 1×1 and 1×2 tiles, which is the same as summing the binomial coefficients along the diagonal.
What are Fibonacci numbers used for in computer science?
Fibonacci numbers appear in algorithms, data structures, and complexity theory:
- • GCD worst case: The Euclidean algorithm takes the most steps on consecutive Fibonacci inputs, F(n) and F(n+1) require exactly n steps. This proves the algorithm is O(log n).
- • Fibonacci heap: A data structure where the key operation bounds depend on Fibonacci numbers, used in Dijkstra's shortest-path algorithm for dense graphs.
- • Dynamic programming teaching: Computing F(n) is the canonical introductory example for memoisation and bottom-up DP, illustrating the difference between exponential and linear time solutions.
- • Pseudorandom number generation: Lagged Fibonacci generators use the recurrence Fₙ = Fₙ₋ⱼ ⊕ Fₙ₋ₖ (with XOR or other operations) to produce pseudorandom sequences with long periods.