Fibonacci number calculator
Binet's formula gives the nth Fibonacci number in closed form from the golden ratio. Because it involves sqrt(5), it is computed here at 45 digits and then rounded to the exact integer.
Fibonacci number
832 040
- The one before it
- 514 229
- Ratio to the previous term Converges on the golden ratio, 1.6180339887...
- 1.618 033 988 748 203 621 3
- Before rounding
- 832 040
Show the working
- n = 30
- root5 = sqrt(5) = 2.236 07
- psi = (1 - 2.236 07) / 2 = -0.618 034
- Before rounding = (phi^30 - -0.618 034^30) / 2.236 07 = 832 040
- Fibonacci number = round(832 040) = 832 040
- The one before it = 30 > 0 ? round((phi^(30-1) - -0.618 034^(30-1)) / 2.236 07) : 0 = 514 229
- Ratio to the previous term = 514 229 > 0 ? 832 040 / 514 229 : 0 = 1.618 03
Values are shown to six significant figures here; the arithmetic itself runs on exact fractions and is only rounded where a number is printed.
Scenarios & local history
Compare a saved scenario
Recent calculations
The formula
- F(n) = (phi^n - psi^n) / sqrt(5), with phi = (1+sqrt5)/2 and psi = (1-sqrt5)/2
- The result is always an integer, which is why the raw value rounds cleanly.
A double-precision implementation of this formula starts returning the wrong integer around n = 71. This one does not.