Fibonacci Sequence Generator
Last updated: 15 August 2026
Reviewed by Gavin Meiring, Lead research and primary author ยท Doctoral Candidate (Corporate Governance) ยท Research and drafting assisted by AI
Fibonacci Sequence Generator
Generate the Fibonacci sequence up to 200 terms. The default pair produces the canonical F(0)=0, F(1)=1, F(n)=F(n-1)+F(n-2) sequence. Custom starting values give Lucas-like variants (set a=2, b=1 for Lucas numbers).
Introduction
The Fibonacci sequence is one of the most famous and widely encountered patterns in all of mathematics. It begins 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, โฆ with each term after the first two equal to the sum of the two terms immediately before it. Leonardo of Pisa, nicknamed Fibonacci, described the sequence in his 1202 book Liber Abaci, though Indian mathematicians had studied the same recurrence centuries earlier.
What makes Fibonacci numbers so compelling is their dual nature. On one hand, the rule is utterly simple: F(n) = F(nโ1) + F(nโ2). On the other, the sequence encodes deep properties of the golden ratio, traces its appearance through pinecones and sunflowers, and surfaces in algorithms that power modern computing. This generator uses BigInt arithmetic so it can produce exact values for any term up to F(200), a 42-digit number that would overflow IEEE-754 double-precision floating point past about F(78).
How to Use This Tool
- Enter the number of terms to generate (1 to 200).
- Optionally change the starting pair (default 0, 1).
- Click Calculate.
- Read the sequence and the running sum.
The starting pair lets you explore any sequence that satisfies the Fibonacci recurrence. (0, 1) gives the canonical Fibonacci numbers; (2, 1) gives the Lucas numbers; (1, 3) gives a less famous but mathematically valid sequence. Every such sequence has a closed-form expression in terms of the golden ratio.
The Formula
Fibonacci recurrence: F(n) = F(nโ1) + F(nโ2), with F(0) = 0 and F(1) = 1.
The sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, โฆ
Lucas numbers: L(n) uses the same recurrence but starts with L(0) = 2, L(1) = 1: 2, 1, 3, 4, 7, 11, 18, 29, โฆ
Closed form (Binet): F(n) = (ฯโฟ โ ฯโฟ) / โ5, where ฯ = (1+โ5)/2 โ 1.6180 and ฯ = (1โโ5)/2 โ โ0.6180.
Approximation: F(n) โ ฯโฟ / โ5 (for large n).
The matrix form is equally elegant: [F(n+1), F(n); F(n), F(nโ1)] = [[1,1],[1,0]]โฟ. Raising the 2ร2 Fibonacci matrix to the nth power gives the nth Fibonacci number, which is why F(n) can be computed in O(log n) time by fast exponentiation.
Worked Examples
First 10 Fibonacci numbers (default a=0, b=1): 0, 1, 1, 2, 3, 5, 8, 13, 21, 34. The sum is 88.
First 10 Lucas numbers (a=2, b=1): 2, 1, 3, 4, 7, 11, 18, 29, 47, 76. The sum is 198.
F(20) by Binet: (1.6180ยฒโฐ โ (โ0.6180)ยฒโฐ) / โ5 โ (15126.99 โ 0.00046) / 2.23607 โ 6765.0. F(20) = 6765 exactly.
Growth rate: F(n+1)/F(n) approaches ฯ โ 1.61803 (the golden ratio). The ratio converges quickly; F(13)/F(12) = 233/144 โ 1.61806.
Sum identity in action: The sum of the first 10 Fibonacci numbers (F(0) through F(9)) is 88. By the identity ฮฃ F(i) for i=0..n = F(n+2) โ 1, this should equal F(11) โ 1 = 89 โ 1 = 88. โ
Identity F(n)ยฒ + F(n+1)ยฒ = F(2n+1): For n=5: 5ยฒ + 8ยฒ = 25 + 64 = 89 = F(11). This is the famous Cassini-like identity that pops up in many Fibonacci proofs.
Negative indices: The recurrence can be extended backwards. F(โ1) = 1, F(โ2) = โ1, F(โ3) = 2, F(โ4) = โ3, โฆ following the rule F(โn) = (โ1)โฟโบยน ยท F(n). For example, F(โ5) = 5.
Where It Shows Up
- Rabbit population problem, Leonardo Fibonacci's original 1202 model: "How many pairs of rabbits are produced from one pair in a year?"
- Spirals in nature, pinecone bracts, sunflower seed heads, nautilus shells, pineapple scales are arranged in Fibonacci spirals.
- Plant phyllotaxis, leaves on a stem grow at the golden angle (~137.5ยฐ) to maximise sunlight.
- Financial retracements, traders use 23.6%, 38.2%, 61.8% (all derived from Fibonacci ratios) as support/resistance levels.
- Music and poetry, composers use Fibonacci rhythm (e.g. Bรฉla Bartรณk); syllable patterns sometimes match F(n).
- Computer science, Fibonacci heaps, search algorithms, AVL tree balance, the Fibonacci coding scheme.
- Art and architecture, the Parthenon, da Vinci's compositions, and Mondrian's grids have been (sometimes contentiously) linked to ฯ.
- Puzzle solving, the minimum number of moves to solve a Tower of Hanoi with n disks is 2โฟ โ 1, but the optimal strategy for the Reve's puzzle (4-peg variant) is given by the Frame-Stewart algorithm and closely mirrors the recursive structure of Fibonacci.
Common Mistakes
- Starting at F(1)=1 instead of F(0)=0. The convention matters, some texts omit F(0). F(10) is 55 if you count from F(0); 89 if you start at F(1).
- Confusing Fibonacci with Lucas numbers. Lucas numbers use the same recurrence but a different starting pair.
- Approximating large F(n) with floating-point. Beyond about F(78), IEEE-754 doubles overflow. Use BigInt.
- Expecting the ratio to reach ฯ quickly. The convergence is fast but not instant, F(7)/F(6) is only โ 1.625.
- Forgetting the F(0) term. Many introductory books begin the sequence at 1, 1, 2, 3, 5, โฆ and never define F(0). If you see F(10) = 89 in one source and 55 in another, the discrepancy is almost always about whether F(0) counts.
- Believing the wild claims about Fibonacci in nature. Some popular accounts overstate the prevalence of Fibonacci spirals. Many plants follow non-Fibonacci patterns (e.g., rational phyllotaxis), and "Fibonacci" stock-trading levels have no statistical edge over random in backtests.
Frequently Asked Questions
What is the Fibonacci sequence?
The Fibonacci sequence starts 0, 1, 1, 2, 3, 5, 8, 13, 21, โฆ Each term after the first two is the sum of the two preceding terms. It was described by Leonardo of Pisa ("Fibonacci") in his 1202 book Liber Abaci, though earlier Indian mathematicians had the same idea.
What is the golden ratio?
The golden ratio ฯ = (1+โ5)/2 โ 1.61803 is the limit of F(n+1)/F(n) as n โ โ. It appears throughout art, architecture, and nature, but most of those claims are weaker than they sound.
How do Lucas numbers relate?
Lucas numbers L(n) use the same recurrence as Fibonacci numbers but start L(0)=2, L(1)=1: 2, 1, 3, 4, 7, 11, 18, 29, 47, 76, โฆ. Every Lucas number equals F(nโ1) + F(n+1).
How large can the numbers get?
F(100) is about 354 ร 10ยฒโฐ, 21 digits. F(200) is about 2.8 ร 10โดยน, 42 digits. BigInt handles these exactly; floating-point overflows at about F(78).
What is the Fibonacci coding?
Fibonacci coding encodes any positive integer as a binary string ending with "11", where no two consecutive 1s appear earlier. It is theoretically optimal for large integers but rarely used in practice.
Is the sum of the first n Fibonacci numbers equal to F(n+2) โ 1?
Yes. The sum of F(1) through F(n) equals F(n+2) โ 1. So summing the first 10 terms (0+1+1+2+3+5+8+13+21+34) gives 88, and F(12) โ 1 = 144 โ 1 = 143โฆ wait, the first term is F(0) here, so the formula needs adjustment. The sum of F(0) through F(n) equals F(n+2) โ 1, and the sum of F(1) through F(n) also equals F(n+2) โ 1.
Why does this generator accept a starting pair?
Different starting pairs produce different sequences that all satisfy the same recurrence. (0, 1) gives Fibonacci; (2, 1) gives Lucas; (1, 3) gives a less famous but mathematically valid sequence. Some of these sequences have interesting closed forms or combinatorial interpretations.
Are Fibonacci numbers prime?
Sometimes. F(3)=2, F(4)=3, F(5)=5, F(7)=13, F(11)=89, F(13)=233, F(17)=1597, F(23)=28657, F(29)=514229 are all prime. F(43)=433494437 is prime. Beyond F(43), no Fibonacci prime is known (it is conjectured there are infinitely many, but unproven). Note that F(n) can only be prime when n itself is prime, except for n=4, which gives F(4)=3.
References
- Leonardo Fibonacci, Liber Abaci (1202), original presentation of the sequence.
- OEIS A000045, canonical Fibonacci sequence entry.
- Koshy, "Fibonacci and Lucas Numbers with Applications", comprehensive textbook reference.
Related Tools
- GCD Calculator, greatest common divisor of two integers.
- Prime Checker, test whether a number is prime.
- Factor Calculator, list all factors of an integer.
Practical Tips
- For small terms (n < 78): floating-point arithmetic is sufficient and fast.
- For larger terms (n โฅ 78): this generator switches to JavaScript
BigInt, which handles arbitrary-precision integers natively. - For Lucas numbers: set starting pair A = 2 and B = 1.
- For Tribonacci or higher recurrences: not supported here, they use a different recurrence (sum of the three preceding terms), and a separate tool handles them.
- For checking primality of F(n): use the related Prime Checker on the output term rather than doing it inline.
- For modular arithmetic on F(n): if you only need F(n) mod m (not the full value), a matrix-exponentiation method runs in O(log n) time and avoids large numbers entirely.
Practical Notes
Keep the Fibonacci Sequence Generator inputs and output together if you might revisit the calculation; a short note of the values used makes the result reproducible. The Fibonacci Sequence Generator computes locally in your browser, so nothing about your inputs is transmitted or stored.
Quick-Start Workflow
Enter the value, pick the unit you have, pick the unit you want, and read the Fibonacci Sequence Generator result. For most conversions that is the whole Fibonacci Sequence Generator workflow; the extra fields on the form are for edge cases and precision control.
Common Pitfalls
Three pitfalls catch most Fibonacci Sequence Generator users: mixing up source and destination conventions, losing precision through multiple chained conversions when a single direct conversion would preserve it, and assuming the tool knows context it cannot infer. For each of these, the cure is to state the assumption explicitly when using the Fibonacci Sequence Generator, then check it against the output.
When this tool is the right one For quick lookups and standard conversions, the Fibonacci Sequence is fast and reliable.
For projects that require audit-grade precision (regulatory filings, scientific publications, engineering specifications),