Fibonacci Sequence Calculator
Generates Fibonacci sequences with custom starting values and computes the nth term or cumulative sum using Binet's formula. Use it for math coursework, algorithm analysis, or exploring the golden ratio.
About this calculator
The Fibonacci sequence is defined by the recurrence F(n) = F(n−1) + F(n−2), with standard seeds F(0) = 0 and F(1) = 1. Binet's closed-form formula computes the nth term directly without iteration: F(n) = (φⁿ − ψⁿ) / √5, where φ = (1 + √5) / 2 ≈ 1.618 (the golden ratio) and ψ = (1 − √5) / 2 ≈ −0.618. The formula works because φ and ψ are roots of the characteristic equation x² = x + 1. The sum of the first n terms satisfies S(n) = F(n+2) − 1, which the calculator implements via the same Binet expression shifted by two. For custom starting values (F₀ = a, F₁ = b), the nth term scales accordingly.
How to use
Find the 10th Fibonacci number using standard seeds F₀ = 0, F₁ = 1. Set n_terms = 10, start_a = 0, start_b = 1, calculation_type = 'nth_term'. Binet's formula gives F(10) = (φ¹⁰ − ψ¹⁰) / √5. φ¹⁰ ≈ 122.9919, ψ¹⁰ ≈ 0.0081, so F(10) = (122.9919 − 0.0081) / 2.2361 ≈ 122.984 / 2.2361 ≈ 55. The calculator rounds to the nearest integer, giving 55. Verify by listing: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 — the 10th term (0-indexed) is indeed 55. ✓
Frequently asked questions
What is Binet's formula and why does it give exact integers from irrational numbers?
Binet's formula, F(n) = (φⁿ − ψⁿ)/√5, expresses Fibonacci numbers in terms of the irrational golden ratio φ = (1+√5)/2 and its conjugate ψ = (1−√5)/2. Despite involving irrationals, the result is always an integer because φ and ψ are roots of the same integer-coefficient polynomial, so their powers combine to cancel all irrational parts. In practice, |ψ| < 1 means ψⁿ → 0 rapidly, so F(n) is simply the nearest integer to φⁿ/√5. For very large n, floating-point rounding errors accumulate, so iterative methods are preferred for precision beyond roughly n = 70.
How does the ratio of consecutive Fibonacci numbers relate to the golden ratio?
As n increases, the ratio F(n+1)/F(n) converges to φ = (1+√5)/2 ≈ 1.6180339…. For small n the ratio oscillates — F(2)/F(1) = 1, F(3)/F(2) = 2, F(5)/F(4) = 1.6667 — but it settles quickly: F(13)/F(12) = 233/144 ≈ 1.6181. This connection to φ appears in nature (spiral phyllotaxis in sunflowers and pinecones), in Renaissance art and architecture, and in efficient search algorithms. The golden ratio is also the positive solution to the equation x² = x + 1, which is the characteristic equation of the Fibonacci recurrence.
What is the sum of the first n Fibonacci numbers and how is it calculated?
The sum of the first n Fibonacci numbers (F(1) through F(n), 1-indexed) equals F(n+2) − 1. This elegant identity — sometimes called the Fibonacci identity for sums — can be proved by induction or by telescoping the recurrence. For example, summing F(1) through F(7): 1+1+2+3+5+8+13 = 33, and F(9) − 1 = 34 − 1 = 33. ✓ The calculator implements this using Binet's formula evaluated at n+1, giving a direct closed-form answer without iterating over every term. This is especially handy when you need the cumulative sum for large n.