Fibonacci Calculator
Calculator Use
With the Fibonacci calculator you can generate a list of Fibonacci numbers from start and end values of n. You can also calculate a single number in the Fibonacci Sequence, Fn, for any value of n up to n = ±500.
Fibonacci Sequence
The Fibonacci Sequence is a set of numbers such that each number in the sequence is the sum of the two numbers that immediatly preceed it.
\[ F_{0} = 0,\quad F_{1} = F_{2} = 1, \]and
\[ F_{n}=F_{n-1}+F_{n-2} \]For example, calculating F4
\[ F_{4}=F_{4-1}+F_{4-2} \] \[ F_{4}=F_{3}+F_{2} \] \[ F_{4}=2+1 \] \[ F_{4}=3 \]The first 15 numbers in the sequence, from F0 to F14, are
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377
Fibonacci Sequence Formula
The formula for the Fibonacci Sequence to calculate a single Fibonacci Number is:
\[ F_{n}={\dfrac{(1+\sqrt{5})^{n}-(1-\sqrt{5})^{n}}{2^{n}\sqrt{5}}} \]or
Fn = ( (1 + √5)^n - (1 - √5)^n ) / (2^n × √5)
for positive and negative integers n.
A simplified equation to calculate a Fibonacci Number for only positive integers of n is:
\[ F_{n}=\left[{\dfrac{(1+\sqrt{5})^{n}}{2^{n}\sqrt{5}}}\right] \]or
Fn = [( (1 + √5)^n ) / (2^n × √5)]
where the brackets in [x] represent the nearest integer function. Simply put, this means to round up or down to the closest integer.
A more compact version of the formula used is:
\[ F_{n} = \dfrac{ \phi^{n} - \psi^{n} }{ \sqrt{5}} \]or
Fn = ( φ^n - ψ^n ) / √5
where φ, the Greek letter phi, is the Golden Ratio φ = (1 + √5) / 2 ≈ 1.618034... and ψ, the Greek letter psi, is ψ = (1 - √5) / 2 ≈ -0.618034...
Since it can be shown that ψ^n is small and gets even smaller as n gets larger, when only working with positive integers of n, the compact Fibonacci Number formula is true:
\[ F_{n} = \left[ \dfrac{\phi^n}{\sqrt{5}} \right] = \left[ {\dfrac{(1+\sqrt{5})^{n}}{2^{n}\sqrt{5}}}\right]\]where the brackets in [x] represent the nearest integer function as defined above.
Negative Fibonacci Numbers
Unless stated otherwise, formulas above will hold for negative values of n however, it could be easier to find Fn and solve for F-n using the following equation.
\[ F_{-n}=(-1)^{n+1}F_{n} \]Putting it another way, when -n is odd, F-n = Fn and when -n is even, F-n = -Fn.
If you are generating a sequence of -n by hand and working toward negative infinity, you can restate the sequence equation above and use this as a starting point:
\[ F_{0} = 0,\quad F_{1} = F_{2} = 1, \]and
\[ F_{n}=F_{n+2}-F_{n+1} \]For example with n = -4 and referencing the table below
\[ F_{-4}=F_{-4+2}-F_{-4+1} \] \[ F_{-4}=F_{-2}-F_{-3} \] \[ F_{-4}=-1-2 \] \[ F_{-4}=-3 \]F-9 to F9
References
Knuth, D. E., The Art of Computer Programming. Volume I. Fundamental Algorithms, Addison-Wesley, 1997, Boston, Massachusetts. pages 79-86
Chandra, Pravin and Weisstein, Eric W. "Fibonacci Number." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/FibonacciNumber.html