login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A006928
a(n) = length of (n+1)st run, with initial terms 1, 2.
(Formerly M0070)
24
1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1
OFFSET
1,2
REFERENCES
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
LINKS
Eric Weisstein's World of Mathematics, Kolakoski Sequence.
FORMULA
a(n) = A000002(n+1), n > 1.
EXAMPLE
Start with [ 1,2 ]. a(1)=1, so the second run has length 1, so a(3) must be 1. a(2)=2, so the third run has length 2, so a(4) must also be 1 and a(5) must be 2. a(3)=1, so the 4th run has length 1, so a(6) must be 1; etc. - Labos Elemer
MATHEMATICA
a = {1, 2}; Do[AppendTo[a, 1+Mod[n, 2]], {n, 2, 80}, {i, a[[n]]}]; a (* Jean-François Alcover, Aug 09 2016, adapted from PARI *)
PROG
(PARI) a=[ 1, 2 ]; for(n=2, 80, for(i=1, a[ n ], a=concat(a, 1+(n%2)))); a
CROSSREFS
Essentially the same as Kolakoski sequence A000002.
Sequence in context: A086412 A192006 A378285 * A087890 A245077 A008676
KEYWORD
nonn,easy,nice
STATUS
approved