What Is the Fibonacci Sequence?
The Fibonacci sequence is a series of numbers where each term is the sum of the two terms before it. The sequence starts with 0 and 1, then continues: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, and so on. Written as a formula, F(n) = F(n minus 1) + F(n minus 2), with F(0) = 0 and F(1) = 1.
The sequence is named after Leonardo of Pisa, known as Fibonacci, who introduced it to Western European mathematics in his 1202 book Liber Abaci. He used it to model the growth of a hypothetical rabbit population: start with one pair of rabbits, each pair produces a new pair every month, and the new pairs start reproducing after one month. The total number of pairs each month follows the Fibonacci sequence.
The sequence appears throughout nature, art, and mathematics. For related number theory tools, try our Prime Number Calculator or Factor Calculator.
What This Calculator Does
This tool has two modes. In nth term mode, enter a number n and it returns F(n), the nth Fibonacci number, using BigInt precision so results are exact even for very large terms. In sequence mode, enter a count and it generates the first that many Fibonacci numbers. Both modes also show the ratio of consecutive terms, which approaches the golden ratio as n increases.
- Inputs: A term number n (0 to 10,000) for nth term mode, or a count (1 to 100) for sequence mode
- Outputs: The exact Fibonacci number or sequence, nearby terms, and the golden ratio approximation
How the Calculation Works
The Recurrence Relation
F(0) = 0
F(1) = 1
F(n) = F(n - 1) + F(n - 2) for n >= 2
This is a linear recurrence relation. The naive recursive approach (calling F(n) which calls F(n minus 1) and F(n minus 2)) is extremely slow for large n because it recomputes the same values many times. The time complexity is exponential, roughly 1.618 to the power n. This calculator instead uses iteration: it starts from F(0) and F(1) and adds forward, which runs in linear time and computes F(10000) instantly.
BigInt Precision
Fibonacci numbers grow exponentially. F(100) has 21 digits, F(1000) has 209 digits, and F(10000) has 2,090 digits. Standard JavaScript numbers lose precision beyond 15 to 16 significant digits. This calculator uses BigInt, which represents integers of arbitrary size with exact precision, so F(10000) is computed correctly to all 2,090 digits.
The Golden Ratio Connection
The ratio of consecutive Fibonacci numbers converges to the golden ratio, written as phi and equal to (1 plus the square root of 5) divided by 2, approximately 1.6180339887. The ratio F(10) / F(9) = 55 / 34 = 1.6176, which is already close. By F(40) / F(39), the ratio matches phi to 10 decimal places. This convergence is not a coincidence; it follows directly from Binet's formula, which expresses F(n) in closed form using phi.
F(n) = (phi^n - (1-phi)^n) / sqrt(5)
where phi = (1 + sqrt(5)) / 2 = 1.6180339887...
How to Use the Calculator
- Choose a mode: find the nth term or generate a sequence
- For nth term mode, enter the term number n (0 to 10,000)
- For sequence mode, enter how many terms to generate (1 to 100)
- The result, nearby terms, and golden ratio approximation appear instantly
- Use the copy button to copy the result
Example Calculations
Example 1: F(10) = 55
A middle school student in Portland enters 10 to find the 10th Fibonacci number. The calculator returns 55. The sequence up to that point is 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55. She can see that 55 = 34 + 21, confirming the recurrence. The nearby terms card shows F(8) through F(12) so she can verify the pattern continues.
Example 2: F(100) = 354224848179261915075
A computer science student in Austin enters 100 to see how large Fibonacci numbers get. The result is 354,224,848,179,261,915,075, a 21-digit number. A standard calculator would show this as 3.542e20, losing the exact value. The BigInt precision in this tool preserves every digit. The ratio F(100) / F(99) matches the golden ratio to 10 decimal places.
Example 3: Generating 20 Terms
A teacher in Denver switches to sequence mode and enters 20 to generate the first 20 Fibonacci numbers for a worksheet. The calculator lists: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181. She copies the list and prints it for her class. The golden ratio card shows F(19) / F(18) = 4181 / 2584 = 1.6180340557, which matches phi to 6 decimal places.
Real-World Scenarios
Plant Biology and Phyllotaxis
The Fibonacci sequence appears in the arrangement of leaves, seeds, and petals in plants. Sunflower seed heads typically contain spirals of 34 and 55, or 55 and 89, both consecutive Fibonacci numbers. Pinecones have spirals of 5 and 8. The reason is that an angle of approximately 137.5 degrees between successive leaves (the golden angle, derived from the golden ratio) packs leaves most efficiently without overlap. A botanist at a university in California might use this calculator to verify the Fibonacci counts observed in a field study of sunflower varieties.
Algorithm Analysis and the Fibonacci Heap
In computer science, Fibonacci numbers appear in the analysis of algorithms. The Fibonacci heap data structure, used in Dijkstra's shortest path algorithm, has time complexities expressed in terms of Fibonacci numbers. A software engineer studying for a technical interview in Seattle might use this calculator to generate test cases for a dynamic programming exercise that computes Fibonacci numbers efficiently, comparing the naive recursive approach (exponential time) with the iterative approach (linear time).
Agile Planning and Story Points
Many agile development teams estimate task complexity using the modified Fibonacci sequence: 1, 2, 3, 5, 8, 13, 21, 34, 55. The gaps between numbers grow because estimating larger tasks is inherently less precise. A scrum master at a fintech company in New York uses this calculator during sprint planning to remind the team of the sequence and explain why the numbers are not arbitrary. The relationship to the golden ratio gives the sequence its natural-feeling progression.
Common Mistakes to Avoid
- Starting with 1, 1 instead of 0, 1: The modern convention starts the sequence with F(0) = 0. Some older texts start with 1, 1, which shifts every index by one. This calculator uses F(0) = 0, so F(10) = 55, not 89.
- Using naive recursion for large n: The recursive formula F(n) = F(n minus 1) + F(n minus 2) is mathematically correct but computationally catastrophic for large n. F(50) by naive recursion takes millions of calls. Always use iteration or memoization for practical computation.
- Losing precision with floating point: F(79) already exceeds the maximum safe integer in JavaScript (2 to the 53rd power minus 1). Using standard numbers beyond that point gives wrong answers. This calculator uses BigInt to avoid this trap.
- Confusing the golden ratio with the sequence: The golden ratio is a single constant, approximately 1.618. The Fibonacci sequence is a series of integers. The connection is that the ratio of consecutive Fibonacci terms approaches the golden ratio, not that the sequence equals the golden ratio.
Limitations of This Calculator
This calculator computes Fibonacci numbers up to F(10000), which has 2,090 digits. Beyond that, the computation time and memory for BigInt arithmetic grow significantly. The sequence mode is limited to 100 terms to keep the display readable. The golden ratio approximation uses standard floating point division, which loses precision for very large terms; for n above roughly 70, the ratio display is approximate. This tool does not compute the Lucas sequence (a related sequence starting with 2 and 1) or generalized Fibonacci sequences with custom starting values.
Authoritative Research & Resources
- Maths Is Fun - Fibonacci Sequence - A clear introduction to the Fibonacci sequence with interactive examples, the rabbit problem from Liber Abaci, and the connection to the golden ratio. Suitable for students and general readers.
- OEIS A000045 - Fibonacci Numbers - The On-Line Encyclopedia of Integer Sequences entry for the Fibonacci sequence, maintained by Neil Sloane. It lists formulas, references, and connections to hundreds of other integer sequences.
- Ron Knott's Fibonacci Pages (University of Surrey) - An extensive academic resource covering Fibonacci numbers in nature, the golden ratio, Binet's formula, and the mathematics of phyllotaxis. Referenced widely in number theory education.
- LibreTexts Mathematics - Number Theory - A peer-reviewed open-access resource covering recurrence relations, the Fibonacci sequence, and the proof that the ratio of consecutive terms converges to the golden ratio. College-level treatment with worked examples.