Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Fibonacci Sequence Calculator

How to use Fibonacci Sequence Calculator
  1. Pick a mode with the four tabs across the top of the card: List first N, List a – b, Test a number or Lookup by index; the ? beside each tab describes it. Learn more about the modes
  2. In List first N, type how many terms to show in Show first and click Update; the cards give the count, the largest term and the sum, and the tiles list every term. Learn more about listing terms
  3. In List a – b, type the From index and the To index and click List range; a red box explains a bad range. Learn more about ranges
  4. In Test a number, type a positive integer in Test number and click Check; a green box names the index, a red box says it is not a Fibonacci number. Learn more about the test
  5. In Lookup by index, type the position in Index n and click Get term. Learn more about lookups
  6. The panel on the right explains the current mode and walks through the arithmetic with your own numbers; it changes with every tab and click. Learn more about the panel





Listing the First N Terms

DemoTen terms, thirty terms, the cap, one term
Step 0 of 4
The explorer opens on the List first N tab, one of four tabs across the top of the card; the small ? beside each tab shows what the mode does. Type how many terms you want in the Show first box and click Update or press Enter. Three cards answer at once: Showing gives the count, Largest the last term with its index, and Sum the total of the listed terms, which for Fibonacci numbers is FN+2−1F_{N+2} - 1. Under the cards every term is laid out as a tile with its index above its value, so F1=1F_1 = 1 to FNF_N can be read in order.

The box accepts 11 to 100100: 1010 gives F10=55F_{10} = 55 with the sum 143143, 3030 gives F30=832,040F_{30} = 832,040 with the sum 2,178,3082,178,308, and 200200 is capped at 100100 terms, ending at F100=354,224,848,179,261,915,075F_{100} = 354,224,848,179,261,915,075 with the sum 927,372,692,193,078,999,175927,372,692,193,078,999,175; a single term gives F1=1F_1 = 1. Large values are printed with thousands separators. A count of 0, a decimal or an empty box is refused with "Enter a positive integer." There is no Reset button: type a new count and click Update again. The panel on the right, List first N, states the rule the tiles come from, and its walkthrough repeats the last term and the sum with your own NN. What the terms are is explained in what is the fibonacci sequence.

Listing a Range of Indexes

DemoThe range tab, a new range, two bad ranges
Step 0 of 4
Click the List a – b tab to list the terms between two positions instead of starting from 11. Type the From index and the To index and click List range or press Enter. The cards give the Count b−a+1b - a + 1, the Smallest term FaF_a and the Largest term FbF_b, and the tiles below list every term in between with its index. The tab opens with 55 to 1515, 11 terms from F5=5F_{5} = 5 to F15=610F_{15} = 610; indexes 1010 to 2020 give 11 terms from 5555 to 6,7656,765.

Both boxes must hold positive integers, the first no larger than the second, and the range may hold at most 100100 terms; otherwise a red box explains: "Enter two positive integer indexes", "From-index must be less than or equal to to-index", or "Range too wide — cap is 100 terms". The panel on the right, List a – b, explains the mode, and its walkthrough names the smallest and largest term of your range. The rule each tile uses is explained in the recurrence and binet's formula.

Testing a Number

DemoThe test tab, a non-member, a member, 0
Step 0 of 4
Click the Test a number tab to ask whether a given positive integer is a Fibonacci number. Type it in the Test number box and click Check or press Enter. A green box with a tick answers yes and names the index, as for the opening value 144144, which is F12F_{12}; a red box with a cross answers no, as for 100100, and the walkthrough on the right then shows the two nearest Fibonacci numbers, F11=89F_{11} = 89 and F12=144F_{12} = 144. A large value is handled the same way: 6,7656,765 is F20F_{20}.

The box takes positive integers only; 00, a negative number or a decimal is refused with "Enter a positive integer". The test behind the answer is exact: the explorer uses the identity that mm is a Fibonacci number exactly when 5m2+45m^2 + 4 or 5m2−45m^2 - 4 is a perfect square; if it is, the index is found, otherwise the two nearest Fibonacci numbers are shown, so no list has to be searched. The panel on the right, Test a number, states this rule, and its walkthrough carries out the arithmetic for your number. The rule itself is explained in the membership test — gessel's identity.

Looking Up a Term by Index

DemoThe lookup tab, two indexes, n = 0
Step 0 of 4
Click the Lookup by index tab to compute one term directly. Type the position in the Index n box and click Get term or press Enter. Two cards answer: Index repeats nn and Value gives FnF_n with its index as a subscript. The tab opens with n=50n = 50, which gives F50=12,586,269,025F_{50} = 12,586,269,025; n=60n = 60 gives 1,548,008,755,9201,548,008,755,920 and n=90n = 90 gives 2,880,067,194,370,816,1202,880,067,194,370,816,120. The box takes positive integers only; 00 is refused with "Enter a positive integer index".

The panel on the right has two parts in every mode. How it works names the rule the mode uses, here Fn=Fn−1+Fn−2F_n = F_{n-1} + F_{n-2} with F1=F2=1F_1 = F_2 = 1, and links to the section of this page that explains it; Walkthrough applies the rule to the numbers you typed, so for the lookup it shows the arithmetic with your nn filled in. Both change as soon as you switch tabs or click a button. The rule and where it comes from are in the recurrence and binet's formula.

What is the Fibonacci Sequence?

The Fibonacci sequence is defined by the linear recurrence

Fn=Fn−1+Fn−2F_n = F_{n-1} + F_{n-2}


with initial conditions F1=F2=1F_1 = F_2 = 1. The first terms are:

1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,…1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, \ldots


Each term is the sum of the two before. Despite the simplicity of the rule, the sequence has profound connections to algebra, geometry, number theory, and the natural world.

Historical origin. Named after Leonardo Fibonacci of Pisa, who introduced the sequence to Western mathematics in his 1202 book Liber Abaci through a problem about rabbit populations. The sequence was known earlier in Indian mathematics, particularly in Sanskrit prosody.

Index conventions. This explorer uses F1=F2=1F_1 = F_2 = 1. Other conventions start at F0=0,F1=1F_0 = 0, F_1 = 1 (giving the same sequence shifted by one). Be careful when comparing references.

Exact computation. Fibonacci numbers grow exponentially — F100F_{100} has 21 digits, F1000F_{1000} has 209 digits. The explorer uses arbitrary-precision integers (BigInt) so every term is exact at any index, with no floating-point error.

For deeper coverage see Fibonacci sequence, golden ratio, and linear recurrence.

The definition is given in definition and the sequence is placed among the others in Fibonacci numbers.

The closed form is derived in Binet.

The identities the test rests on are collected in identities and properties.

More identities, with proofs, are in identities and properties; the companion sequence is Lucas numbers.

The sequence is summarised in Fibonacci at a glance.

The Recurrence and Binet's Formula

The recurrence. Fn=Fn−1+Fn−2F_n = F_{n-1} + F_{n-2} is a second-order linear recurrence with constant coefficients. Its characteristic equation is

x2=x+1x^2 = x + 1


with roots

φ=1+52≈1.61803398…,ψ=1−52≈−0.61803398…\varphi = \frac{1 + \sqrt{5}}{2} \approx 1.61803398\ldots, \quad \psi = \frac{1 - \sqrt{5}}{2} \approx -0.61803398\ldots


φ\varphi is the golden ratio.

Binet's formula. The closed-form expression for FnF_n is

Fn=φn−ψn5F_n = \frac{\varphi^n - \psi^n}{\sqrt{5}}


Since ∣ψ∣<1|\psi| < 1, ψn\psi^n shrinks rapidly to zero, and FnF_n is well-approximated by φn/5\varphi^n / \sqrt{5} for large nn.

Why the formula gives an integer. φ\varphi and ψ\psi are irrational, but the combination φn−ψn\varphi^n - \psi^n always lies in 5Z\sqrt{5} \mathbb{Z} — the difference of conjugate irrational powers cancels into a rational multiple of 5\sqrt{5}. Dividing by 5\sqrt{5} gives an integer.

Practical computation. Binet's formula has floating-point limitations: for large nn, the formula needs more precision than typical doubles provide. The recurrence (or matrix exponentiation, or fast doubling) is preferred for exact computation, which is why this explorer uses BigInt iteration.

Matrix form. (Fn+1Fn)=(1110)n(10)\begin{pmatrix} F_{n+1} \\ F_n \end{pmatrix} = \begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix}^n \begin{pmatrix} 1 \\ 0 \end{pmatrix}. Matrix exponentiation by repeated squaring computes FnF_n in O(log⁡n)O(\log n) multiplications.

The Membership Test — Gessel's Identity

Given a positive integer mm, how do you decide whether mm is a Fibonacci number?

Gessel's identity (1972). mm is a Fibonacci number if and only if

5m2+4or5m2−45 m^2 + 4 \quad \text{or} \quad 5 m^2 - 4


is a perfect square. Once one of these is a perfect square, the index nn is found by iterating the Fibonacci recurrence until Fn=mF_n = m.

Why two cases. The identity has both +4+4 and −4-4 because Fibonacci numbers at even and odd indexes behave differently with respect to the underlying Lucas-Fibonacci identity. Specifically:

• 5Fn2+4=Ln2+4Ln−45 F_n^2 + 4 = L_n^2 + 4 L_n - 4 — wait, the cleaner statement: 5Fn2−4(−1)n=Ln25 F_n^2 - 4 (-1)^n = L_n^2, where LnL_n is the nn-th Lucas number.

So 5Fn2+45 F_n^2 + 4 is a perfect square (equal to Ln2L_n^2) when nn is odd, and 5Fn2−45 F_n^2 - 4 is a perfect square when nn is even. Together, the two cases cover all Fibonacci numbers.

Example. Is 144 Fibonacci? Compute 5⋅1442=1036805 \cdot 144^2 = 103680. Then 103680+4=103684103680 + 4 = 103684; 103684≈321.99…\sqrt{103684} \approx 321.99\ldots, not a perfect square. Try 103680−4=103676103680 - 4 = 103676; 103676=322\sqrt{103676} = 322, a perfect square. So 144 is Fibonacci. Iterating the recurrence: 1,1,2,3,5,8,13,21,34,55,89,1441, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 — that's F12F_{12}. So 144=F12144 = F_{12}.

Non-example. Is 100 Fibonacci? 5⋅1002=500005 \cdot 100^2 = 50000. Then 50000+4=5000450000 + 4 = 50004; 50004≈223.61\sqrt{50004} \approx 223.61, not a perfect square. 50000−4=4999650000 - 4 = 49996; 49996≈223.59\sqrt{49996} \approx 223.59, not a perfect square either. So 100 is not Fibonacci. The nearest are F11=89F_{11} = 89 and F12=144F_{12} = 144.

BigInt arithmetic. For large mm, the squares 5m2±45 m^2 \pm 4 exceed safe-integer precision. The explorer uses BigInt for these checks, so the test is exact for any input within input-parsing range.

Properties and Identities

Fibonacci numbers satisfy hundreds of identities. A representative selection:

• Cassini's identity: Fn−1Fn+1−Fn2=(−1)nF_{n-1} F_{n+1} - F_n^2 = (-1)^n. The product of two terms straddling FnF_n differs from Fn2F_n^2 by exactly ±1\pm 1.
• Catalan's identity: Fn2−Fn−rFn+r=(−1)n−rFr2F_n^2 - F_{n-r} F_{n+r} = (-1)^{n-r} F_r^2. A generalization of Cassini's.
• d'Ocagne's identity: FmFn+1−Fm+1Fn=(−1)nFm−nF_m F_{n+1} - F_{m+1} F_n = (-1)^n F_{m-n}.
• Fast doubling: F2n=Fn(2Fn+1−Fn)F_{2n} = F_n (2 F_{n+1} - F_n) and F2n+1=Fn2+Fn+12F_{2n+1} = F_n^2 + F_{n+1}^2. These give O(log⁡n)O(\log n) computation by recursion.
• Sum identity: F1+F2+⋯+Fn=Fn+2−1F_1 + F_2 + \cdots + F_n = F_{n+2} - 1.
• Sum of squares: F12+F22+⋯+Fn2=FnFn+1F_1^2 + F_2^2 + \cdots + F_n^2 = F_n F_{n+1}.
• Sum of odd-indexed: F1+F3+F5+⋯+F2n−1=F2nF_1 + F_3 + F_5 + \cdots + F_{2n-1} = F_{2n}.
• GCD identity: gcd⁡(Fm,Fn)=Fgcd⁡(m,n)\gcd(F_m, F_n) = F_{\gcd(m, n)}. A beautiful number-theoretic property — the GCD of Fibonacci numbers is itself a Fibonacci number.
• Divisibility: Fm∣FnF_m \mid F_n if and only if m∣nm \mid n (for m≥3m \geq 3). Fibonacci-number divisibility mirrors index divisibility.
• Zeckendorf's theorem: every positive integer has a unique representation as a sum of non-consecutive Fibonacci numbers.

Fibonacci in Nature and Application

Fibonacci numbers appear with striking frequency in biological and physical contexts.

Phyllotaxis. The arrangement of leaves around a stem, seeds in a sunflower, scales on a pinecone, and bracts on a pineapple often follows Fibonacci-based spirals. A sunflower head typically has 34 spirals in one direction and 55 in the other (both Fibonacci numbers). The golden angle ≈137.5°\approx 137.5°, derived from φ\varphi, is the optimal packing angle.

Branching patterns. Some tree species (notably elm and rose) produce branches in counts that grow by Fibonacci numbers.

Pinecone and pineapple spirals. Pinecones have spiral counts in pairs like (5, 8), (8, 13), or (13, 21) — consecutive Fibonacci numbers.

Honeybee genealogy. Male bees (drones) have only one parent; female bees have two. Counting ancestors back, a drone's ancestor counts form the Fibonacci sequence: 1, 1, 2, 3, 5, ...

Cryptography and algorithms. Fibonacci heaps achieve O(1)O(1) amortized insertion, and Fibonacci coding is used in some data-compression schemes.

Financial markets. Some traders use Fibonacci retracements (38.2%, 50%, 61.8%) derived from Fibonacci ratios for technical analysis. The mathematical basis is more cultural than rigorous.

Counting compositions. Fn+1F_{n+1} counts the ways to write nn as an ordered sum of 1s and 2s — closely related to tiling and combinatorial problems.

Art and architecture. The golden ratio and Fibonacci proportions appear in classical Greek architecture, Renaissance art, and modern design. Some claims are exaggerated; others are well-documented.

Fibonacci and the Golden Ratio

The golden ratio φ=(1+5)/2≈1.618\varphi = (1 + \sqrt{5})/2 \approx 1.618 is the key analytic object behind the Fibonacci sequence.

Limit of ratios. As n→∞n \to \infty:

lim⁡n→∞Fn+1Fn=φ\lim_{n \to \infty} \frac{F_{n+1}}{F_n} = \varphi


Even for modest nn, the ratio is close to φ\varphi: F11/F10=89/55=1.61818…F_{11}/F_{10} = 89/55 = 1.61818\ldots.

Why phi. φ\varphi is the unique positive number satisfying φ=1+1/φ\varphi = 1 + 1/\varphi, equivalently φ2=φ+1\varphi^2 = \varphi + 1. This equation matches the structure of the Fibonacci recurrence. Solving x2−x−1=0x^2 - x - 1 = 0 gives φ\varphi and ψ=(1−5)/2\psi = (1 - \sqrt{5})/2.

The golden ratio's role in Binet's formula. Fn=(φn−ψn)/5F_n = (\varphi^n - \psi^n)/\sqrt{5}. Since ∣ψ∣<1|\psi| < 1, the ψn\psi^n term decays, and Fn≈φn/5F_n \approx \varphi^n / \sqrt{5} to within 1/21/2 for all n≥1n \geq 1.

The golden rectangle. A rectangle with side ratio φ:1\varphi : 1 has the property that cutting off a square leaves a smaller rectangle with the same side ratio. Drawing diagonals of these nested rectangles approximates the logarithmic spiral, which itself is closely related to natural growth patterns.

Other irrational appearances. The continued-fraction expansion of φ\varphi is [1;1,1,1,…][1; 1, 1, 1, \ldots] — the simplest possible continued fraction. This makes φ\varphi the most irrational number in the sense of being hardest to approximate by rationals.

The ratio is the subject of the golden ratio.

Common Mistakes

• Index convention confusion. Two common conventions: F0=0,F1=1F_0 = 0, F_1 = 1 (Knuth, OEIS) or F1=F2=1F_1 = F_2 = 1 (this explorer, many classical references). They give the same sequence shifted by one. Always check the convention before quoting a value.

• Floating-point precision errors. Binet's formula or naive double-precision computation breaks at moderate nn. F80F_{80} already has 17 digits — exceeding double precision. Use BigInt or symbolic computation for exact values.

• Misapplying Gessel's identity. Both 5m2+45m^2 + 4 and 5m2−45m^2 - 4 must be checked; only one will be a perfect square (or neither, if mm is not Fibonacci). Skipping one case incorrectly rejects half of all Fibonacci numbers.

• Naive recursive computation. Computing FnF_n via the naive recursion fib(n)=fib(n−1)+fib(n−2)\text{fib}(n) = \text{fib}(n-1) + \text{fib}(n-2) has exponential time complexity. Use memoization, iteration, fast doubling, or matrix exponentiation for O(n)O(n) or O(log⁡n)O(\log n).

• Confusing Fibonacci with Lucas numbers. Lucas numbers LnL_n satisfy the same recurrence with L1=1,L2=3L_1 = 1, L_2 = 3. They share many identities with Fibonacci but are a distinct sequence: 1, 3, 4, 7, 11, 18, 29, 47, ...

• Overclaiming nature appearances. Fibonacci spirals appear in many plants but not all. Spurious claims (e.g., "the Mona Lisa uses golden-ratio proportions") are common but often unsupported by careful measurement.

Index conventions and recursive definitions are explained in definition and notation and explicit and recursive definitions.