editing
approved
editing
approved
William Kolakoski, <a href="https://www.jstor.org/stable/2313883">Problem 5304</a>, Amer. Math. Monthly, Vol. 72, No. 8 (1965), p. 674; <a href="https://www.jstor.org/stable/2314839">Self Generating Runs</a>, Solution to Problem 5304 by Necdet Üçoluk, Vol. 73, No. 6 (1966), pp. 681-682.
approved
editing
editing
approved
Minor edits in to example and PARI code made by M. F. Hasler, May 07 2014
approved
editing
proposed
approved
editing
proposed
Comment from Kevin Ryde, Oct 07 2024: The second one is clear. Values are only ever 1 or 2 so "a(n-1) + a(n-2) - 3" asks whether a(n-1)=a(n-2). Knowing any run length is at most 2 then means a(n) and a(n-3) are equal. The first one is similar: if a(n-1)=a(n-2) then a(n) is a "flip" to a(n) = 3-a(n-1). The key in both cases is that 1,1,1 and 2,2,2 never occur.
Comment from Kevin Ryde, Oct 07 2024: The above formulas are true: The parts identify when terms are same or different and they hold for any sequence of 1's and 2's with run lengths 1 or 2.
approved
editing
proposed
approved
editing
proposed
KolakoskiSeq[n_Integer] := Block[{a = {1, 2, 2}}, Fold[Join[#1, ConstantArray[Mod[#2, 2] + 1, #1[[#2]]]] &, a, Range[3, n]]]; KolakoskiSeq[999] (* Mikk Heidemaa, Nov 01 2024 *)
approved
editing