Fibonacci Sequence Calculator
Calculate any Fibonacci number by position or generate the full sequence up to a given term. Useful for algorithm study, mathematical modeling, and exploring the golden ratio.
About this calculator
The Fibonacci sequence is defined by the recurrence F(1) = 1, F(2) = 1, and F(n) = F(n−1) + F(n−2) for n > 2, producing 1, 1, 2, 3, 5, 8, 13, 21, … For any specific term, Binet's formula gives a closed-form solution: F(n) = (φⁿ − ψⁿ) / √5, where φ = (1 + √5) / 2 ≈ 1.61803 (the golden ratio) and ψ = (1 − √5) / 2 ≈ −0.61803. Because |ψ| < 1, ψⁿ → 0 for large n, meaning F(n) ≈ φⁿ / √5 rounded to the nearest integer. Binet's formula is particularly elegant because it produces an integer result from irrational inputs. The ratio of consecutive Fibonacci numbers converges to the golden ratio φ as n increases.
How to use
To find the 10th Fibonacci number, enter 10 in the 'Position' field. The calculator applies Binet's formula: φ = (1 + √5) / 2 ≈ 1.61803, ψ = (1 − √5) / 2 ≈ −0.61803. Then F(10) = (1.61803¹⁰ − (−0.61803)¹⁰) / √5 = (122.9919 − 0.0081) / 2.2361 ≈ 122.9838 / 2.2361 ≈ 55. The 10th Fibonacci number is 55. Verify by counting: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 ✓.
Frequently asked questions
What is Binet's formula and how does it calculate Fibonacci numbers directly?
Binet's formula, F(n) = (φⁿ − ψⁿ) / √5, computes the nth Fibonacci number without iterating through the whole sequence. Here φ = (1 + √5)/2 is the golden ratio and ψ = (1 − √5)/2 is its conjugate. Although both φ and √5 are irrational, the formula always produces an exact integer when n is a positive integer. This makes it useful for calculating very large Fibonacci numbers quickly, though floating-point precision limits may require arbitrary-precision arithmetic for extremely large n.
How does the Fibonacci sequence relate to the golden ratio?
As n grows, the ratio of consecutive Fibonacci numbers F(n+1)/F(n) converges to the golden ratio φ ≈ 1.61803. This is not a coincidence: since F(n) ≈ φⁿ/√5, the ratio F(n+1)/F(n) ≈ φ^(n+1)/φⁿ = φ. The golden ratio appears throughout nature in spiral arrangements of seeds, shells, and leaves, and Fibonacci numbers are the integer approximations of successive powers of φ. This connection is why the sequence fascinates mathematicians, architects, and biologists alike.
What are practical applications of the Fibonacci sequence in computer science?
Fibonacci numbers appear in algorithm analysis — the worst case of the Euclidean GCD algorithm occurs with consecutive Fibonacci inputs. Fibonacci heaps are a data structure used in Dijkstra's shortest-path algorithm. The sequence is also used in pseudo-random number generation and search techniques like Fibonacci search, which divides arrays in golden-ratio proportions. In dynamic programming, computing Fibonacci numbers efficiently is a classic example of memoization vs. recursion trade-offs.