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
- 1Enter any non-negative integer (or click F(12), F(20), 1000, or 21-digit F(100)).
- 2Inspect the exact perfect-square proof, index F(k), and neighboring Fibonacci terms.
- 3Switch to Batch List to classify multiple numbers at once.
Reference Examples & Worked Benchmarks
| n | 5n² ± 4 Square | Fibonacci Index |
|---|---|---|
| 144 | 5(144)² + 4 = 322² | F(12) |
| 6,765 | 5(6765)² + 4 = 15127² | F(20) |
| 1,000 | Neither is a square | Between 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.