Fibonacci Calculator

Enter a position n to find the nth Fibonacci number.

Updated

Enter to calculate Esc to clear

Fibonacci Calculator

Our Fibonacci Calculator finds the nth Fibonacci number F(n) for any position from −100,000 to 100,000. Type n and the answer appears straight away, with the working, the sequence leading up to it, the ratio to the previous term and the number of digits. Every digit is exact, even for F(100,000), which has 20,899 digits, so it is useful for homework, programming exercises and exploring the golden ratio.

Quick answer

The Fibonacci sequence starts with 0 and 1, and every next number is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, … The nth Fibonacci number is written F(n), so F(10) = 34 + 21 = 55. Enter any position above and the calculator shows F(n) instantly.

  • Rule: F(n) = F(n − 1) + F(n − 2), with F(0) = 0 and F(1) = 1
  • Binet’s formula: F(n) = (φn − ψn) ÷ √5, or φn ÷ √5 rounded
  • Golden ratio: F(n + 1) ÷ F(n) gets closer to φ ≈ 1.618 as n grows
  • Examples: F(20) = 6,765, F(50) = 12,586,269,025, F(100) has 21 digits

What Is the Fibonacci Sequence?

The Fibonacci sequence is one of the best-known patterns in mathematics. It starts with 0 and 1, and each new term is the sum of the two terms before it. It is named after Leonardo of Pisa, known as Fibonacci, who described it in his book Liber Abaci in 1202 with a puzzle about breeding rabbits. Here are the first 20 terms:

nF(n)nF(n)
001055
111189
2112144
3213233
4314377
5515610
6816987
713171,597
821182,584
934194,181

The terms grow quickly: each one is about 1.618 times the one before, so F(n) gains roughly one extra digit every five steps. F(100) already has 21 digits and F(1,000) has 209.

The Fibonacci Formula

The rule (recursive formula). Each term is the sum of the previous two, starting from two fixed values:

F(n) = F(n − 1) + F(n − 2)
F(0) = 0, F(1) = 1

Binet’s formula (closed form). F(n) can also be found directly from the golden ratio φ and its partner ψ:

F(n) = (φⁿ − ψⁿ) ÷ √5

φ = (1 + √5) ÷ 2 ≈ 1.6180339887
ψ = (1 − √5) ÷ 2 ≈ −0.6180339887

Shortcut: F(n) = φⁿ ÷ √5, rounded

Binet’s formula is exact on paper, but with ordinary decimal maths it goes wrong from F(71) because of rounding. This calculator instead uses the fast doubling identities F(2k) = F(k) × (2F(k + 1) − F(k)) and F(2k + 1) = F(k)2 + F(k + 1)2 with exact whole numbers, so every digit is right.

Worked Examples

The 7th Fibonacci number. Write out the terms, adding the last two each time:

F(0) to F(7): 0, 1, 1, 2, 3, 5, 8, 13

F(7) = F(6) + F(5) = 8 + 5 = 13

The 22nd Fibonacci number with Binet’s formula.

φ²² ≈ 39,602.99997
φ²² ÷ √5 ≈ 17,711.00001

F(22) = 17,711

A large term. Enter 100 and the calculator gives F(100) = 354,224,848,179,261,915,075. Enter 1000 and it shows 4.346655 × 10²⁰⁸ in short form, while Copy gives all 209 digits.

Fibonacci and the Golden Ratio

Divide each Fibonacci number by the one before it and the answers close in on the golden ratio φ = 1.6180339887…, overshooting and undershooting in turn:

nF(n + 1) ÷ F(n)Ratio
58 ÷ 51.6
1089 ÷ 551.6181818
15987 ÷ 6101.6180328
2010,946 ÷ 6,7651.6180340
30F(31) ÷ F(30)1.6180340

The golden ratio is the number that satisfies φ2 = φ + 1, the same “add the two before” rule that builds the sequence. Its reciprocal is 1 ÷ φ ≈ 0.618, which is where the 61.8% level in trading comes from.

Fibonacci Number Properties

  • Every 3rd term is even: F(3) = 2, F(6) = 8, F(9) = 34.
  • Sum of the terms: F(0) + F(1) + … + F(n) = F(n + 2) − 1, so 0 + 1 + … + 55 = 143 = 144 − 1.
  • Cassini’s identity: F(n − 1) × F(n + 1) − F(n)2 = (−1)n, so 34 × 89 − 552 = 1.
  • GCD of two terms: GCD(F(m), F(n)) = F(GCD(m, n)), so GCD(144, 2,584) = 8 = F(6).
  • Fibonacci test: x is a Fibonacci number when 5x2 + 4 or 5x2 − 4 is a perfect square, as 5 × 212 + 4 = 472.

Negative Positions

The rule can also run backwards, F(n − 2) = F(n) − F(n − 1), which extends the sequence to negative positions. The result is the same numbers with alternating signs, sometimes called negafibonacci numbers:

n: −6 −5 −4 −3 −2 −1 0
F(n): −8 5 −3 2 −1 1 0

F(−n) = (−1)ⁿ⁺¹ × F(n)

Fibonacci in Nature and Trading

Nature. Plants that grow new seeds or leaves at a constant turning angle (about 137.5°, the golden angle) end up with spirals in Fibonacci numbers. Pinecones and pineapples usually show 8 and 13 spirals, and sunflower heads often show 34 and 55, or 55 and 89. Many flowers have 3, 5 or 8 petals. These are strong tendencies, not laws: plenty of exceptions exist.

Trading. Fibonacci retracement levels mark how far a price might fall back after a rise. For a rise from 100 to 200:

LevelWhere it comes fromPrice
23.6%1 ÷ φ³176.4
38.2%1 ÷ φ²161.8
50%Halfway (not a Fibonacci ratio)150
61.8%1 ÷ φ138.2

Retracement levels are a charting convention, not a prediction: prices often pass straight through them.

Fibonacci in Excel and Code

ToolF(n)
Excel / Google Sheets=ROUND(((1+SQRT(5))/2)^A1/SQRT(5), 0)
Excel, as a listA1 = 0, A2 = 1, A3 = A1+A2, fill down
Pythona, b = b, a + b (in a loop)
JavaScript[a, b] = [b, a + b] (use BigInt)

The ROUND formula is exact up to about F(70); after that, rounding errors creep in, and Excel keeps only 15 significant digits anyway. Python integers never overflow; in JavaScript, start the loop with 0n and 1n to use BigInt.

Common Mistakes

  • Off-by-one positions. Starting at 1, 1 instead of 0, 1 shifts every label. Check whether “the 10th term” means F(10) = 55 or F(9) = 34.
  • Plain recursion. fib(n) = fib(n − 1) + fib(n − 2) without memory repeats work; fib(40) makes over 300 million calls. Use a loop or memoization.
  • Overflow. 64-bit integers stop at F(92) and JavaScript numbers are exact only up to F(78).
  • Trusting Binet with decimals. Rounding errors make φn ÷ √5 wrong from F(71) in standard floating-point maths.
  • Calling 50% a Fibonacci level. The 50% retracement is common on charts but is not a Fibonacci ratio.

Key Terms

F(n)
The Fibonacci number at position n, counting F(0) = 0 and F(1) = 1.
Recurrence
A rule that builds each term from earlier ones, here F(n) = F(n − 1) + F(n − 2).
Golden ratio
φ = (1 + √5) ÷ 2 ≈ 1.618, the limit of F(n + 1) ÷ F(n).
Binet
Binet’s formula, which gives F(n) directly from powers of φ and ψ.
Lucas numbers
A sister sequence with the same rule but starting 2, 1: 2, 1, 3, 4, 7, 11, 18, …
Negafibonacci
Fibonacci numbers at negative positions, with alternating signs.

How to Use the Fibonacci Calculator

  1. Enter the position n. Type a whole number in the “Position in the sequence (n)” box, for example 10. Any value from −100,000 to 100,000 works, counting from F(0) = 0 and F(1) = 1.
  2. Read the Fibonacci number. F(n) appears as you type, with the working underneath (for example F(10) = F(9) + F(8) = 34 + 21 = 55). The table below it shows the sequence up to F(n), the two previous terms, the ratio to the previous term and the number of digits. Very long results are shown in short form, such as 4.346655 × 10²⁰⁸ for F(1,000).
  3. Copy the result. Press Copy to copy every digit of F(n), even when the result is shown in short form. Press Clear or Esc to start again.

Example: enter 22 and the result is 17,711, with the working F(22) = F(21) + F(20) = 10,946 + 6,765 = 17,711 and a ratio to the previous term of 1.6180339850.

Who Can Use This Calculator?

Students and TeachersSequences, recursion, proofs and golden ratio projects
ProgrammersChecking loop, recursion and BigInt results against exact values
TradersUnderstanding where retracement ratios such as 61.8% come from
Designers and Curious MindsGolden ratio layouts, spirals and patterns in nature

Frequently Asked Questions (FAQs)

What is the Fibonacci sequence?

It is the list of numbers that starts 0, 1 and continues by adding the two previous numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 and so on. Each number in the list is a Fibonacci number, and F(n) is the one at position n, so F(10) = 55.

What is the formula for the nth Fibonacci number?

The rule is F(n) = F(n − 1) + F(n − 2), with F(0) = 0 and F(1) = 1. There is also a direct formula, Binet’s formula: F(n) = (φn − ψn) ÷ √5, where φ = (1 + √5) ÷ 2 ≈ 1.618 and ψ = (1 − √5) ÷ 2 ≈ −0.618. Because ψn becomes tiny, F(n) is simply φn ÷ √5 rounded to the nearest whole number.

What is the 100th Fibonacci number?

F(100) = 354,224,848,179,261,915,075, a 21-digit number. Some books start counting at F(1) = 1, F(2) = 1, which gives the same answer here, because both conventions give F(1) = F(2) = 1.

Does the Fibonacci sequence start with 0 or 1?

Modern maths starts at F(0) = 0 and F(1) = 1, and this calculator follows that convention. Fibonacci’s own book started with 1, 1, so some sources list 1, 1, 2, 3, 5, … The numbers are the same; only the position labels change, so always check which term a question calls the first.

How is the Fibonacci sequence related to the golden ratio?

Divide any Fibonacci number by the one before it and the answer gets closer and closer to the golden ratio φ ≈ 1.6180339887. 8 ÷ 5 = 1.6, 55 ÷ 34 ≈ 1.6176 and 6,765 ÷ 4,181 ≈ 1.6180339632. Dividing the other way gives 1 ÷ φ ≈ 0.618.

How do you check if a number is a Fibonacci number?

A whole number x is a Fibonacci number exactly when 5x2 + 4 or 5x2 − 4 is a perfect square. For 21, 5 × 441 + 4 = 2,209 = 472, so 21 is a Fibonacci number. For 22, neither 2,424 nor 2,416 is a perfect square, so it is not.

Can n be negative?

Yes. Running the rule backwards gives the negafibonacci numbers: F(−1) = 1, F(−2) = −1, F(−3) = 2, F(−4) = −3 and so on. They are the ordinary Fibonacci numbers with alternating signs: F(−n) = (−1)n+1 × F(n), so F(−8) = −21.

Why does my program give the wrong Fibonacci number?

Ordinary numbers run out of room. A 64-bit integer holds Fibonacci numbers only up to F(92), and JavaScript numbers (doubles) are exact only up to F(78). Binet’s formula with floating-point maths starts giving wrong answers at F(71). Use big integers (Python int, JavaScript BigInt, Java BigInteger) for anything larger. This calculator uses exact whole-number maths for every result.

Where are Fibonacci numbers used?

In nature, the number of spirals in sunflower heads, pinecones and pineapples is usually a Fibonacci number, such as 8 and 13 or 34 and 55. Traders use Fibonacci retracement levels (23.6%, 38.2% and 61.8%) on price charts. Programmers use the sequence to teach recursion and dynamic programming, and in Fibonacci heaps and Fibonacci search. Agile teams estimate tasks in story points of 1, 2, 3, 5, 8 and 13.

Is the Fibonacci Calculator free?

Yes. It is completely free, needs no sign-up, and can be used as many times as you like.

Try our Fibonacci Calculator to find any Fibonacci number instantly, exact to the last digit.