Fibonacci Calculator
The nth Fibonacci or Lucas number exactly, every digit, a list of the first terms, and a test of whether a number is a Fibonacci number and which one.
Result…
How it's calculated
F(0) = 0, F(1) = 1, F(n) = F(n − 1) + F(n − 2) L(0) = 2, L(1) = 1, L(n) = L(n − 1) + L(n − 2) = F(n − 1) + F(n + 1) Fast doubling: F(2k) = F(k)(2F(k + 1) − F(k)), F(2k + 1) = F(k)² + F(k + 1)² x is Fibonacci ⇔ 5x² + 4 or 5x² − 4 is a perfect square
Gives any Fibonacci or Lucas number up to index 10,000 exactly (more than 2,000 digits) using fast doubling with whole-number BigInt arithmetic, along with its digit count, the next term, the sum of all terms up to it and the ratio to the previous term. It lists the first terms, and tests whether a number of up to 5,000 digits is a Fibonacci number with the 5x² ± 4 perfect-square test, giving its index.
Your numbers, step by step
About the Fibonacci calculator
This Fibonacci calculator gives any Fibonacci number up to index 10,000 exactly, with every digit, rather than a rounded decimal. It starts from F(0) = 0 and F(1) = 1, each term being the sum of the two before it. It can also list the first terms, test whether a number of up to 5,000 digits is a Fibonacci number and say which one, and switch to the Lucas numbers (2, 1, 3, 4, 7, …), which follow the same rule. Students use it for sequence and recursion homework, programmers use it to check their own code, and puzzle fans use it to explore the golden ratio. The working shows the fast doubling method used for large indexes, Binet's formula as a check, and the perfect-square test used to recognise a Fibonacci number.
How to use it
- Choose the “Sequence”: Fibonacci or Lucas.
- Under “Find”, pick “The nth term”, “The first terms” or “Is it in the sequence?”.
- Type the “Index n” (0 to 10,000), “How many terms” to list (up to 200), or the “Number to test”.
- Read the exact value, its number of digits, the next term, the sum of the terms so far and the ratio to the previous term.
Worked example
F(50) = 12,586,269,025, an 11-digit number. The next term is F(51) = 20,365,011,074, the sum F(0) + … + F(50) = F(52) − 1 = 32,951,280,098, and F(50) ÷ F(49) = 1.61803398875, already the golden ratio to 12 significant figures. The Lucas number L(50) is 28,143,753,123.
Updated
Questions people ask
How do I calculate the nth Fibonacci number?
Add the two previous terms, starting from 0 and 1. For a large n, the fast doubling identities F(2k) = F(k)(2F(k + 1) − F(k)) and F(2k + 1) = F(k)² + F(k + 1)² reach the answer in about log₂(n) steps instead of n.
What is the formula for the nth Fibonacci number?
Binet's formula gives F(n) = (φⁿ − ψⁿ) ÷ √5, where φ = (1 + √5) ÷ 2 and ψ = (1 − √5) ÷ 2. Because ψⁿ is tiny, F(n) is φⁿ ÷ √5 rounded to the nearest whole number, though decimals lose accuracy for large n.
How can I tell if a number is a Fibonacci number?
A whole number x is a Fibonacci number exactly when 5x² + 4 or 5x² − 4 is a perfect square. For 144, 5 × 144² + 4 = 103,684 = 322², so 144 is a Fibonacci number: F(12).
Why do some books give different indexes?
Some start the sequence at F(1) = F(2) = 1 and leave out F(0) = 0. The numbers have the same indexes either way, but a list that starts at 1, 1 has one fewer term at the front, which is a common source of off-by-one answers.
How are Fibonacci numbers related to Lucas numbers?
Both add the two previous terms, but Lucas numbers start 2, 1. They are linked by L(n) = F(n − 1) + F(n + 1); for example L(10) = 34 + 89 = 123. Both grow by about the golden ratio each step, a pattern also seen in the geometric sequence calculator.