Fibonacci Number Tester
Check if any integer belongs to the Fibonacci sequence instantly. Enter a number to test its Fibonacci status.
What Is a Fibonacci Number?
A Fibonacci number is any number that appears in the classic Fibonacci sequence — the infinite series where each term is the sum of the two preceding terms. The sequence begins with 0 and 1:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610 …
Formally, the Fibonacci sequence is defined by the recurrence relation:
\[ F(0) = 0,\quad F(1) = 1,\quad F(n) = F(n-1) + F(n-2) \text{ for } n \ge 2 \]
Numbers like 0, 1, 2, 3, 5, 8, 13, 21 are Fibonacci numbers. Numbers like 4, 6, 7, 9, 10, 11, 12 are not. This tool lets you quickly test any integer (or a list of integers) to determine whether it belongs to the Fibonacci sequence, and if so, shows its exact position.
How to Use This Tool
Using the Fibonacci Number Tester is simple:
- Enter one or more integers in the left text area — one per line (or multiple space/comma separated on one line).
- Results appear instantly on the right as you type.
- For each number, the tool tells you:
- Whether the number IS or IS NOT a Fibonacci number.
- If it is Fibonacci, its exact index in the sequence (F(0), F(1), F(2), …).
- If it is not Fibonacci, the two nearest Fibonacci numbers that surround it.
- Click the "Sample" button to load example numbers and see the tool in action.
The Math Behind the Fibonacci Test
Rather than generating the entire Fibonacci sequence and searching through it, this tool uses a fast mathematical property discovered by mathematicians:
A positive integer n is a Fibonacci number if and only if one (or both) of the following expressions is a perfect square:
\[ 5n^2 + 4 \quad \text{or} \quad 5n^2 - 4 \]
This elegant identity, known as the Fibonacci square criterion, means the test runs in O(1) constant time — no looping required. For example:
- For n = 5: \( 5(25)+4 = 129 \) (not a perfect square) and \( 5(25)-4 = 121 = 11^2 \) ✔ → Fibonacci!
- For n = 4: \( 5(16)+4 = 84 \) (not) and \( 5(16)-4 = 76 \) (not) → Not Fibonacci.
Why Are Fibonacci Numbers Important?
Fibonacci numbers appear throughout nature, art, and mathematics:
- Nature: The number of petals on flowers, the spiral arrangement of seeds in a sunflower, and the branching of trees often follow Fibonacci patterns.
- The Golden Ratio: The ratio of consecutive Fibonacci numbers converges to \( \phi = \frac{1+\sqrt{5}}{2} \approx 1.618 \), the famous golden ratio.
- Computer Science: Fibonacci heaps, Fibonacci search techniques, and dynamic programming examples are all based on the sequence.
- Cryptography & Finance: Fibonacci retracements are widely used in technical analysis for trading financial markets.
Fibonacci Numbers Up to 1000
For quick reference, here are all Fibonacci numbers up to 1000: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987.
Frequently Asked Questions
Is 0 a Fibonacci number?
Yes! 0 is the very first term of the Fibonacci sequence, denoted F(0) = 0. The sequence starts at 0, not 1. So 0 is indeed a valid Fibonacci number.
Is 1 a Fibonacci number?
Yes, and in fact 1 appears twice in the Fibonacci sequence: F(1) = 1 and F(2) = 1. This tool identifies it as F(1) since it uses the first occurrence.
Can negative numbers be Fibonacci numbers?
The standard Fibonacci sequence only includes non-negative integers (0, 1, 1, 2, 3, 5, …). There is an extension called the "negafibonacci" sequence that handles negative indices, but for the purposes of this tool, only non-negative integers are checked. Negative inputs will return a "Not Fibonacci" result.
What is the largest Fibonacci number this tool can accurately test?
JavaScript's integers are accurate up to 2^53 − 1 (Number.MAX_SAFE_INTEGER ≈ 9 quadrillion). The tool uses this mathematical perfect-square test, which works accurately within JavaScript's safe integer range. For very large numbers, results may not be reliable due to floating-point precision limits.
How fast is this Fibonacci test?
The test uses the mathematical property that n is Fibonacci if and only if 5n² + 4 or 5n² − 4 is a perfect square. This runs in constant O(1) time regardless of how large the number is, making it extremely fast — no need to generate a list of Fibonacci numbers first.
Why does the tool show the "nearest Fibonacci numbers" when a number is not Fibonacci?
Showing the neighboring Fibonacci numbers (the largest Fibonacci number below n and the smallest above n) gives useful context. For example, if you enter 100, you'll see that 89 and 144 are the nearest Fibonacci numbers on either side, which helps you understand how close your number is to the sequence.
Related tools
Your recent visits