Free Online Utility • MATH Studio • Exact BigInt Engine

Test If Number Is Fibonacci

Instantly test whether any integer (even 200+ digits!) belongs to the Fibonacci sequence using Gessel's exact BigInt perfect-square criterion (5n² ± 4), finding its exact index F(k) and neighbors.

Gessel Perfect-Square Test
Exact BigInt Fibonacci Membership
FIBONACCI NUMBER
YES — F(20)
5n² + 4 = 228826129 = 15127² (Perfect Square!)
Exact Index
F(20)
Prev Fib
4181
Next Fib
10946
Uses exact BigInt Newton integer square root on 5n² ± 4Handles 200+ digits

Session Calculation Log

No entries recorded in this session yet.

Complete Technical Guide to Test If Number Is Fibonacci

Ira Gessel's classic 1972 theorem proves a remarkably elegant closed-form membership test: a non-negative integer n is a Fibonacci number if and only if either 5n² + 4 or 5n² − 4 is a perfect square—where the integer square root is in fact the companion Lucas number L(k)!

Using exact BigInt Newton integer square roots, this tool verifies Fibonacci membership for integers with hundreds of digits in under a millisecond, reveals the exact Fibonacci index F(k) and proof square, and brackets non-Fibonacci inputs between their closest neighboring Fibonacci numbers.

Gessel's Exact Perfect-Square Criterion

n is Fibonacci  <=>  (5n² + 4) is a perfect square  OR  (5n² - 4) is a perfect square
Moreover:  5·F(k)² + 4·(-1)^k = L(k)²   (exact Lucas identity!)

Because 5·6765² + 4 = 228,826,129 = 15,127² (= L(20)²), 6,765 is proven instantaneously to be F(20).

How to Use Test If Number Is Fibonacci

  1. 1Enter any non-negative integer (or click F(12), F(20), 1000, or 21-digit F(100)).
  2. 2Inspect the exact perfect-square proof, index F(k), and neighboring Fibonacci terms.
  3. 3Switch to Batch List to classify multiple numbers at once.

Reference Examples & Worked Benchmarks

n5n² ± 4 SquareFibonacci Index
1445(144)² + 4 = 322²F(12)
6,7655(6765)² + 4 = 15127²F(20)
1,000Neither is a squareBetween 987 & 1,597

Practical Applications & Engineering Workflows

Algorithm & Interview Proofs

Verify O(1) arithmetic Fibonacci tests without floating-point sqrt precision bugs.

Lucas–Fibonacci Identity Check

Observe how √(5·F(k)² ± 4) always yields the exact k-th Lucas number L(k).

Accuracy, Edge Cases & Best Practices

  • Exact BigInt Newton isqrt avoids floating-point false positives that plague Math.sqrt() past 10^8.

All calculations execute locally inside your browser using JavaScript with zero server round-trips, guaranteeing instant responsiveness and complete data privacy.

Frequently Asked Questions

Why does standard Math.sqrt(5*n*n + 4) fail for large numbers?
IEEE-754 64-bit floats lose integer precision past 2^53 (~9×10^15), causing false positives for n > 4×10^7. Our BigInt Newton isqrt is 100% exact at any size.
Is 0 considered a Fibonacci number?
Yes—0 is F(0), the very first term of the Fibonacci sequence (5·0² + 4 = 4 = 2²).