Encyclopedia Integer Sequences
Encyclopedia Integer Sequences
Proceedings of the
15th International Conference on Fibonacci Numbers and Their Applications
Institute of Mathematics and Informatics, Eszterházy Károly College
Eger, Hungary, June 25–30, 2012
N. J. A. Sloane
Abstract
We all recognize 0, 1, 1, 2, 3, 5, 8, 13, . . . but what about 1, 2, 4, 6, 3, 9, 12, 8,
10, 5, 15, . . .? If you come across a number sequence and want to know if it has
been studied before, there is only one place to look, the On-Line Encyclopedia
of Integer Sequences (or OEIS). Now in its 49th year, the OEIS contains
over 220,000 sequences and 20,000 new entries are added each year. This
article will briefly describe the OEIS and its history. It will also discuss some
sequences generated by recurrences that are less familiar than Fibonacci’s,
due to Greg Back and Mihai Caragiu, Reed Kelly, Jonathan Ayres, Dion
Gijswijt, and Jan Ritsema van Eck.
Keywords: Fibonacci, sequences, recurrences.
MSC: Primary 11B
in the OEIS [15]. As in the OEIS, we adopt the convention that a(n) denotes the nth term of the
sequence being discussed.
219
220 N. J. A. Sloane
where gpf stands for greatest prime factor (A006530). If we start with 1, 1 we get
1, 1, 2, 3, 5, 2, 7, 3, 5, 2, 7, . . . (1.2)
(A175723), and the cycle 3, 5, 2, 7 repeats for ever. Back and Caragiu show that no
matter what the initial values are, (1.1) always becomes periodic and that 3, 5, 2, 7
is the only nontrivial cycle. On the other hand, consider
1, 1, 1, 3, 5, 3, 11, 19, 11, 41, 71, 41, 17, 43, 101, 23, . . . (1.4)
(A177904), which after 86 steps enters a cycle of length 212. Now it is only a
conjecture that (1.3) always becomes periodic, for any initial values.
Another interesting variant of the Fibonacci sequence2 was very recently intro-
duced into the OEIS by Reed Kelly [12]. Kelly’s recurrence is
a(n − 1) + a(n − 3)
a(n) = , (1.5)
gcd{a(n − 1), a(n − 3)}
1, 1, 1, 2, 3, 4, 3, 2, 3, 2, 2, 5, 7, 9, 14, 3, 4, 9, 4, 2, . . . (1.6)
and it too can be found on the Foundation web site. It is also on YouTube (search
for “OEIS movie”).
5. Puzzles
One of the goals of the OEIS has always been to help people get higher scores on
IQ tests, and the database includes many sequences that have appeared as puzzles.
The following are a few examples. If you can’t solve them, you know where to find
the answers!
I will give three concrete examples of theorems that were discovered with the
help of the OEIS. The first concerns the remainder term in Gregory’s series for
π/2,
π X∞
(−1)k+1 1 1 1
=2 = 2 1 − + − + ··· , (7.1)
2 2k + 1 3 5 7
k=1
which is famous for converging very slowly. In 1987, Joseph North observed that if
one truncates the series after 50,000 terms, the answer is of course wrong. There is
an error in the fifth decimal place. Surprisingly, he noticed that the next nine digits
are correct, then there is an error, then there are nine more correct digits, another
error, and so on. Here is the decimal expansion of the truncated sum followed by
the true value of π/2 (the sequences of digits form A013706 and A019669). The
digits that differ are in bold-face.
1.570796326794896619231321691639751442098584699687 . . . (truncated)
1.570786326794897619231321191639752052098583314687 . . . (true value)
Jonathan Borwein looked up this sequence in [16], and found that (apart from signs)
it appeared to be the Euler numbers, A000364. The end result of this investigation
was a new theorem.
Theorem 7.1 (Borwein, Borwein and Dilcher [4]; see also [3, pp. 28–29], [5]).
N/2 ∞
π X (−1)k+1 X Em
−2 ∼ 2m+1
, (7.2)
2 2k + 1 m=0
N
k=1
The second example is one that I was involved with personally. It began when
Eric W. Weisstein (at Wolfram Research, and creator of MathWorld) wrote to
me about a discovery he had made. He had been classifying real matrices of 0’s
and 1’s according to various properties, and he found that the numbers of such
matrices all of whose eigenvalues were positive were 1, 3, 25, 543, 29281 for matrices
of orders 1, 2, . . . , 5. He observed that these numbers coincided with the beginning
of sequence A003024 (whose definition on the surface seemed to have nothing to do
with eigenvalues), and he conjectured that the sequences should in fact be identical.
He was right, and this led to the following theorem.
Theorem 7.2 ([14]). The number of acyclic directed graphs with n labeled vertices
is equal to the number of n × n matrices of 0’s and 1’s all of whose eigenvalues are
real and positive.
The On-Line Encyclopedia of Integer Sequences 225
The third example is a result of Deutsch and Sagan [8]. It is well-known that
the famous Catalan numbers
1 2n
Cn :=
n+1 n
(A000108) are odd if and only if n = 2k − 1 for some k. Deutsch and Sagan proved
(among other things) an analogous result for the almost equally-famous Motzkin
numbers (A001006),
Xn
n
Mn := Ck .
2k
k=1
lists the numbers whose binary expansion ends with an even number of 0’s (A003159).
0 20 40 60 80 100
n
Figure 1: The first 100 terms of the EKG sequence, with successive
points joined by lines
226 N. J. A. Sloane
1600
1400
1200
1000
a(n)
800
600
400
Jonathan Ayres contributed this to the OEIS in 2001 [1]. The first 18 terms are
1, 2, 4, 6, 3, 9, 12, 8, 10, 5, 15, 18, 14, 7, 21, 24, 16, 20, . . .
(A064413), and the defining recurrence is a(1) = 1, a(2) = 2, and, for n ≥ 3,
a(n) is the smallest natural number not yet in the sequence
which has a common factor > 1 with the previous term.
.
..
1500
..
. .
.
. ..
..
.. .
..
. .
. .
. ..
. .
. .. . ..........
.............. .
1000
..
. ............. .
.. .
. ..... ................ .
. ... ...
. ............ .
. .. . . ........ ..
. .. . . . ......
.................
a(n)
.. .
.....
.
.. ....... .
. .. .. .......... .
. .. .. ........... .
....... .
..
.
....
............. .
.. . .
. . . .... .
... . ............
........... . .. . .. .
.
500
.. .. ........ .
.. . .......... .. . . .
.....
. .. . . . .
. .
..
..
. .
............... . . . . . . ..
.
.... . . ..
. .......... . . . ..
. ... . ........ . .. . .
.. .......... . . .. . . .
.. . . .................. . . . .. .. . .
..
. . . ............ .. . ...
. ...
. . ........... . ... . .
............... .. ... .
..
.................. . . . ... . . .
.
.
.... ... .
.............
0
Thus a(3) must have a common factor with 2, i.e. it must be even, and 4 is the
smallest candidate, so a(3) = 4. The next term must also be even, so a(4) = 6.
The smallest number not yet in the sequence which has a common factor with 6
is 3, so a(5) = 3. Similarly, a(6) = 9, a(7) = 12, a(8) = 8, a(9) = 10, a(11) = 5,
a(12) = 15, and so on. Jeffrey Lagarias, Eric Rains and I studied this sequence in
[13]. We called it the EKG sequence, since it looks like an electrocardiogram when
plotted (Figs. 1, 2).
It is not difficult to show that the primes appear in increasing order, and that
each odd prime p is either preceded by 2p and followed by 3p, or is preceded by
3p and followed by 2p (as we just saw, 3 was preceded by 6 and followed by 9, 5 is
preceded by 10 and followed by 15).6
By definition, no number can can be repeated. But does every number appear?
The answer is Yes.
Theorem 8.1. The EKG sequence is a permutation of the natural numbers.
Sketch of Proof. (i) If infinitely many multiples of some prime p occur in the se-
quence, then every multiple of p must occur. (For if not, let kp be the smallest
missing multiple of p. Every number below kp either appears or it doesn’t, but
once we get to a multiple of p beyond all those terms, the next term must be kp,
which is a contradiction.) (ii) If every multiple of a prime p appears, then every
number appears. (The proof is similar.) (iii) Every number appears. (For if there
are only finitely many different primes among the prime factors of all the terms,
then some prime must divide infinitely many terms, and the result follows from
(i) and (ii). On the other hand, if infinitely many different primes p appear, then
there are infinitely many terms 2p, as noted above, so 2 appears infinitely often,
and again the result follows from (i) and (ii).)
Although the initial terms of the sequence jump around, when we look at the
big picture we find that the points lie very close to three almost-straight lines (Fig.
3). This is somewhat similar to the behavior of the prime numbers, which are
initially erratic, but lie close to a smooth curve (since the nth prime is roughly
n log n) when we look at the big picture – see Don Zagier’s lecture on “The first 50
million prime numbers” [18].
In fact, we have a precise conjecture about the three lines on which the points
lie. We believe – but are unable to prove – that almost all a(n) satisfy the asymp-
totic formula a(n) ∼ n(1 + 1/(3 log n)) (the central line in Fig. 3), and that the
exceptional values a(n) = p and a(n) = 3p, for p a prime, produce the points on
the lower and upper lines. We were able to show that the sequence has essentially
linear growth (there are constants c1 and c2 such that c1 n < a(n) < c2 n for all n),
but the proof of even this relatively weak result was quite difficult. It would be
nice to have better bounds.
6 We conjectured that p was always preceded by 2p rather than 3p. This was later proved by
1 1 2
1 1 2 2 2 3
1 1 2
1 1 2 2 2 3 2
1 1 2
1 1 2 2 2 3
1 1 2
1 1 2 2 2 3 2 2 2 3 2 2 2 3 3 2
1 1 2
1 1 2 2 2 3
1 1 2
1 1 2 2 2 3 2
1 1 2
1 1 2 2 2 3
1 1 2
1 1 2 2 2 3 2 2 2 3 2 2 2 3 3 2 2 2 3 2
The beginning of the sequence is shown in Table 1 (it has been broken up into
sections to show where the curling number drops back to 1):
This sequence was analyzed by Gijswijt, Fokko van de Bult, John Linderman,
Allan Wilks and myself [6]. The first time a 4 appears is at a(220). We computed
several million terms without finding a 5, and for a while we wondered if perhaps
no term greater than 4 was ever going to appear. However, we were able to show
that a 5 does eventually appear, although the universe would grow cold before a
The On-Line Encyclopedia of Integer Sequences 229
direct search would find it. The first 5 appears at about term
23
1010 .
We also showed that the sequence is actually unbounded, and we conjecture that
the first time that a number m (= 5, 6, 7, . . .) appears is at about term number
·m−1
··
4
23
2 ,
a tower of height m − 1.
Our arguments could be considerably simplified if the Curling Number Conjec-
ture were known to be true. This states that:
If one starts with any initial sequence of integers, and extends
it by repeatedly calculating the curling number and appending
it to the sequence, the sequence will eventually reach 1.
The conjecture is still open. One way to tackle it is to consider starting se-
quences S0 that contain only 2’s and 3’s, and to see how far such a sequence will
extend (by repeatedly appending the curling number) before reaching a 1.
Let µ(n) denote the maximal length that can be achieved before a 1 appears,
for any starting sequence S0 consisting of n 2’s and 3’s. For n = 4, for example,
S0 = 2 3 2 3 produces the sequence
232322231 ...,
and no other starting string does better, so µ(4) = 8. The Curling Number Conjec-
ture would imply that µ(n) < ∞ for all n. Reference [6] gave µ(n) for 1 ≤ n ≤ 30,
and Benjamin Chaffin and I have determined µ(n) for all n ≤ 48 [7]. By making
certain plausible assumptions about S0 , we have also computed lower bounds on
µ(n) (which we conjecture to be the true values) for all n ≤ 80. The results are
shown in Table 2 and Figure 4. The values of µ(n) also form sequence A094004 in
[15].
n 1 2 3 4 5 6 7 8 9 10 11 12
µ(n) 1 4 5 8 9 14 15 66 68 70 123 124
n 13 14 15 16 17 18 19 20 21 22 23 24
µ(n) 125 132 133 134 135 136 138 139 140 142 143 144
n 25 26 27 28 29 30 31 32 33 34 35 36
µ(n) 145 146 147 148 149 150 151 152 153 154 155 156
n 37 38 39 40 41 42 43 44 45 46 47 48
µ(n) 157 158 159 160 161 162 163 164 165 166 167 179
n 49 50 51 52 53 54 55 56 57 58 59 60
µ(n) 180 181 182 183 184 185 186 187 188 189 190 191
n 61 62 63 64 65 66 67 68 69 70 71 72
µ(n) 192 193 194 195 196 197 198 200 201 202 203 204
n 73 74 75 76 77 78 79 80 81 82 83 84
µ(n) 205 206 207 209 250 251 252 253 ? ? ? ?
Table 2: Lower bounds on µ(n), the record for a starting sequence
of n 2’s and 3’s. Entries for n ≤ 48 are known to be exact (and we
conjecture the other entries are exact).
We have not succeeded in finding any algebraic constructions for good starting
sequences. For more about the Curling Number Conjecture see [7].
The On-Line Encyclopedia of Integer Sequences 231
n Starting sequence
1 2
2 22
4 2323
6 222322
8 23222323
9 223222323
10 2323222322
11 22323222322
14 22323222322323
19 2232232322232232232
22 2322322323222323223223
48 223223232223222322322232232322232223223222322323
Table 3: Starting sequences of n 2’s and 3’s for which µ(n) >
µ(n − 1) + 1. This is complete for n ≤ 48 and is believed to be
complete for n ≤ 67.
Since a(1) = 0 has never appeared before, a(2) = 0. Now 0 has appeared one
step before, at a(1), so a(3) = 1. We have not seen a 1 before, so a(4) = 0. We
had an earlier 0 at a(2), so a(5) = 4 − 2 = 2. This is the first 2 we have seen, so
a(6) = 0. And so on. The first 36 terms are shown in Table 4.
0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5,
0, 2, 6, 5, 4, 0, 5, 3, 0, 3, 2, 9,
0, 4, 9, 3, 6, 14, 0, 6, 3, 5, 15, 0,
5, 3, 5, 2, 17, 0, 6, 11, 0, 3, 8, 0, . . .
Table 4: The first 48 terms of Van Eck’s sequence (A181391)
Figure 5 shows a scatter-plot of the first 800 terms. The plot suggests that
after n terms, there are occasionally terms around n, or in other words that
lim sup a(n)/n ≈ 1. This is confirmed by looking at the first million terms, and the
data also strongly suggests that every number appears in the sequence. However,
at present these are merely conjectures.
232 N. J. A. Sloane
Van Eck was able to show that there are infinitely many 0’s in the sequence,
or, equivalently, that the sequence is unbounded.
Theorem 8.2 (Van Eck, personal communication). The sequence contains in-
finitely many 0’s.
Proof. Suppose, seeking a contradiction, that there are only finite number of 0’s in
the sequence. Then after a certain point no new terms can appear, so the sequence
is bounded. Let M be the largest term. This means that any block of M successive
terms determines the sequence. But there are only M M different possible blocks.
So a block must repeat and the sequence is eventually periodic. Furthermore, the
period cannot contain a 0.
Suppose the period has length p, and starts at term r, with a(r) = x, . . . , a(r +
p − 1) = z, a(r + p) = x, . . . . There is another z after q ≤ p steps, which is
immediately followed by q. But this q implies that a(r − 1) = z. Therefore the
periodic part really began at step r − 1.
Repeating this argument shows that the periodic part starts at a(1). But a(1) =
0, and the periodic part cannot contain a 0. Contradiction.
9. Conclusion
I will end with a few general remarks.
The On-Line Encyclopedia of Integer Sequences 233
• The OEIS needs more editors. If you are interested in helping, please write
to me or one of the other Editors-in-Chief. There are no formal duties,
everything is done on a volunteer basis, and you will get to see a lot of
interesting new problems.
References
[1] J. Ayres, Sequence A064413 in [15], Sept. 30, 2001.
[2] G. Back and M. Caragiu, The greatest prime factor and recurrent sequences, Fib.
Quart., 48 (2010), 358–362.
[3] J. M. Borwein, D. H. Bailey and R. Girgensohn, Experimentation in Mathematics,
A K Peters, Natick, MA, 2004.
[4] J. M. Borwein, P. B. Borwein and K. Dilcher, Pi, Euler numbers and asymptotic
expansions, Amer. Math. Monthly, 96 (1989), 681–687.
[5] J. M. Borwein and R. M. Corless, Review of “An Encyclopedia of Integer Sequences”
by N. J. A. Sloane and Simon Plouffe, SIAM Review, 38 (1996), 333–337.
[6] F. J. van der Bult, D. C. Gijswijt, J. P. Linderman, N. J. A. Sloane and A. R. Wilks,
A slow-growing sequence defined by an unusual recurrence, J. Integer Sequences, 10
(2007), Article 07.1.2.
[7] B. Chaffin, J. P. Linderman, N. J. A. Sloane and A. R. Wilks, On curling numbers
of integer sequences, Preprint, 2012; arXiv:1212.6102.
[8] E. Deutsch and B. E. Sagan, Congruences for Catalan and Motzkin numbers and
related sequences, J. Num. Theory, 117 (2006), 191–215.
[9] J. R. van Eck, Sequence A181391 in [15], Oct. 17, 2010.
[10] D. Gijswijt, Sequence A090822 in [15], Feb. 27, 2004.
[11] P. Hofman and M. Pilipczuk, A few new facts about the EKG sequence, J. Integer
Sequences, 11 (2008), Article 08.4.2.
[12] R. Kelly, Sequence A214551 in [15], July 20, 2012.
[13] J. C. Lagarias, E. M. Rains and N. J. A. Sloane, The EKG sequence, Experimental
Math., 11 (2002), 437–446.
234 N. J. A. Sloane