PokerAgile

Fibonacci numbers: the first 100, formula and calculator

The Fibonacci sequence is a sequence of whole numbers in which each term is the sum of the two terms before it. It starts with 1 and 1.

The first 20 Fibonacci numbers are 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1,597, 2,584, 4,181, 6,765.

Fibonacci sequence calculator

F(10) = 55

Fibonacci number list: the first 100

RankFibonacci number
F(1)1
F(2)1
F(3)2
F(4)3
F(5)5
F(6)8
F(7)13
F(8)21
F(9)34
F(10)55
F(11)89
F(12)144
F(13)233
F(14)377
F(15)610
F(16)987
F(17)1,597
F(18)2,584
F(19)4,181
F(20)6,765
F(21)10,946
F(22)17,711
F(23)28,657
F(24)46,368
F(25)75,025
F(26)121,393
F(27)196,418
F(28)317,811
F(29)514,229
F(30)832,040
F(31)1,346,269
F(32)2,178,309
F(33)3,524,578
F(34)5,702,887
F(35)9,227,465
F(36)14,930,352
F(37)24,157,817
F(38)39,088,169
F(39)63,245,986
F(40)102,334,155
F(41)165,580,141
F(42)267,914,296
F(43)433,494,437
F(44)701,408,733
F(45)1,134,903,170
F(46)1,836,311,903
F(47)2,971,215,073
F(48)4,807,526,976
F(49)7,778,742,049
F(50)12,586,269,025
F(51)20,365,011,074
F(52)32,951,280,099
F(53)53,316,291,173
F(54)86,267,571,272
F(55)139,583,862,445
F(56)225,851,433,717
F(57)365,435,296,162
F(58)591,286,729,879
F(59)956,722,026,041
F(60)1,548,008,755,920
F(61)2,504,730,781,961
F(62)4,052,739,537,881
F(63)6,557,470,319,842
F(64)10,610,209,857,723
F(65)17,167,680,177,565
F(66)27,777,890,035,288
F(67)44,945,570,212,853
F(68)72,723,460,248,141
F(69)117,669,030,460,994
F(70)190,392,490,709,135
F(71)308,061,521,170,129
F(72)498,454,011,879,264
F(73)806,515,533,049,393
F(74)1,304,969,544,928,657
F(75)2,111,485,077,978,050
F(76)3,416,454,622,906,707
F(77)5,527,939,700,884,757
F(78)8,944,394,323,791,464
F(79)14,472,334,024,676,221
F(80)23,416,728,348,467,685
F(81)37,889,062,373,143,906
F(82)61,305,790,721,611,591
F(83)99,194,853,094,755,497
F(84)160,500,643,816,367,088
F(85)259,695,496,911,122,585
F(86)420,196,140,727,489,673
F(87)679,891,637,638,612,258
F(88)1,100,087,778,366,101,931
F(89)1,779,979,416,004,714,189
F(90)2,880,067,194,370,816,120
F(91)4,660,046,610,375,530,309
F(92)7,540,113,804,746,346,429
F(93)12,200,160,415,121,876,738
F(94)19,740,274,219,868,223,167
F(95)31,940,434,634,990,099,905
F(96)51,680,708,854,858,323,072
F(97)83,621,143,489,848,422,977
F(98)135,301,852,344,706,746,049
F(99)218,922,995,834,555,169,026
F(100)354,224,848,179,261,915,075

The recurrence

F(n) = F(n-1) + F(n-2), with F(1) = 1 and F(2) = 1

Example: F(7) = F(6) + F(5) = 8 + 5 = 13. The rule needs the two terms before the one you want, so reaching F(50) means computing the first 49 terms.

Some authors add a term in front, F(0) = 0. The sequence then reads 0, 1, 1, 2, 3, 5, 8. The numbers do not change and F(1) is still 1. On this page, rank 1 is the first 1.

Binet's formula

F(n) = (φn - ψn) / √5
φ = (1 + √5) / 2
ψ = (1 - √5) / 2

It gives F(n) without the earlier terms. The term ψn / √5 is always smaller than 0.5, so F(n) is the integer closest to φn / √5. At rank 10, φ10 / √5 is 55.0036 and F(10) = 55.

Jacques Binet published the formula in 1843. Abraham de Moivre had already written it in 1730, in his Miscellanea Analytica. Daniel Bernoulli and Leonhard Euler knew it too.

In 64-bit floating point, Binet's formula returns the right integer up to rank 70. At rank 71 the rounding lands on the wrong number.

Fibonacci numbers and the golden ratio

Divide a term by the one before it. The higher the rank, the closer the result gets to the golden ratio, φ = (1 + √5) / 2, about 1.6180339887.

Rank nF(n) / F(n-1)Ratio
21 / 11.0000000000
32 / 12.0000000000
55 / 31.6666666667
1055 / 341.6176470588
206,765 / 4,1811.6180339632
40102,334,155 / 63,245,9861.6180339887

The ratio lands above φ, then below it, in turn: 2, then 1.5, then 1.667, then 1.6. The astronomer Johannes Kepler had already noted that these ratios close in.

Where it comes from: the rabbit problem

Leonardo of Pisa, known as Fibonacci, sets this problem in his book of calculation, Liber Abaci, in 1202. A pair of rabbits is put in an enclosure. A pair takes one month to mature, then produces a new pair every month. No rabbit dies. How many pairs are there after a year?

MonthPairs
11
21
32
43
55
68
12144

In month 1 the pair is young. In month 2 it is adult. In month 3 it has its first young and the enclosure holds 2 pairs.

Each month keeps every pair from the month before and adds one new pair for each pair that existed two months earlier. That is the recurrence. Month 12 has 144 pairs, which is F(12).

In the book the first pair is already adult and breeds in the first month, so Fibonacci writes 2, 3, 5, 8, 13 and reaches 377 pairs after twelve months, which is F(14).

The sequence was known before him. Indian scholars used it to count the possible rhythms of a line of Sanskrit verse, among them Virahanka around 700 and Hemachandra around 1150. The name "Fibonacci sequence" comes from the French mathematician Édouard Lucas, in the 19th century.

Fibonacci numbers in nature

  • Sunflowers. The seeds form spirals that turn in both directions. A common count is 34 one way and 55 the other. Large heads can show 55 and 89.
  • Pine cones. The scales most often form 5 and 8 spirals, or 8 and 13.
  • Honeybees. A male hatches from an unfertilised egg, so he has a mother and no father. A female has two parents. Going up a male's family tree gives 1 parent, 2 grandparents, 3 great-grandparents, then 5 and 8 ancestors.

These counts are common without being a rule. A study published in 2016 in Royal Society Open Science covered 657 sunflowers. Of 768 spiral counts judged reliable, 565 were Fibonacci numbers. The rest were not.

The nautilus shell is often shown next to the golden ratio. That is a mistake. Its spiral does grow by a constant factor, but the factor is not φ: published measurements put the length-to-height ratio near 1.3, far from 1.618.

Fibonacci in Python and JavaScript

Python

def fibonacci(n):
    a, b = 0, 1
    for _ in range(n):
        a, b = b, a + b
    return a

print(fibonacci(100))
# 354224848179261915075

JavaScript

function fibonacci(n) {
  let a = 0n, b = 1n;
  for (let i = 0; i < n; i++) {
    [a, b] = [b, a + b];
  }
  return a;
}

console.log(fibonacci(100));
// 354224848179261915075n

Both functions do n additions and keep two numbers in memory. Python integers have no size limit. In JavaScript, the Number type is exact up to 253 - 1, a limit F(79) already passes. BigInt, written with an n after the number, gives the exact value.

The recursive version, where the function calls itself twice, repeats the same work over and over. For F(30) it makes more than a million calls.

FAQ

What is the formula for Fibonacci numbers?

F(n) = F(n-1) + F(n-2), with F(1) = 1 and F(2) = 1. Binet's formula gives a term without the ones before it: F(n) is the integer closest to φ to the power n divided by √5, where φ = (1 + √5) / 2.

What is the 10th Fibonacci number?

F(10) = 55, counting from F(1) = F(2) = 1. The first ten Fibonacci numbers are 1, 1, 2, 3, 5, 8, 13, 21, 34 and 55.

Does the Fibonacci sequence start with 0 or 1?

Both conventions are in use. With F(1) = F(2) = 1 the sequence starts 1, 1, 2, 3, 5. With F(0) = 0 it starts 0, 1, 1, 2, 3. The numbers are the same.

What is the 100th Fibonacci number?

F(100) = 354,224,848,179,261,915,075. It has 21 digits.

See also

Sources: OEIS A000045, OEIS A001605, Swinton and Ochu, 2016, Bartlett, Nexus Network Journal, MathWorld.