OFFSET
2,3
COMMENTS
The Kolakoski sequence A000002 has a fractal structure that appears in the infinite number of iterations and reverse iterations of itself that it contains. Each iteration develops itself in two branches, a right branch in the direct sense, and a left branch in the reverse sense, e.g., 122-1-221121. This sequence gives the length of the full iterated word with its right and left branches starting at position n (with a length = 0 if A000002(n) = 2 <> A000002(1) = 1).
Each iterated word is generated by a preceding and shorter one, starting with 12 or 21 with the 1 in odd position. 12 for example gives, as long as the image of the initial 1 remains in odd position: 12 > 2-1-221 > 122-1-221121 > ... (21 generates the same succession with words in reverse order). The right branch is thus always formed by a term of A054351 (successive generations of the OK sequence), and the left branch by a term of the same sequence in reverse order.
The lengths of the 2 branches are never equal, because a fully symmetric iterated word would necessitate at the beginning the word 12121, which never appears in the OK sequence (it would need 111 before in the OK sequence to appear), but the 2 branches cannot differ by more than two successive generations, again because a greater difference would imply an impossible word at the beginning, namely 1-1221-1.
The iterated words are initiated by the 1's in the OK sequence, but the 1's in pairs 11 can only lead to very short iterated words: (1)-1-2(1) or (1)-1-221(2), or the same in reverse order, with values in this sequence of +/-2 or +/-4. On the contrary, each of the single 1's (212) in the OK sequence (except the first) is associated with an iterated word of length at least five, and (conjecture) it is likely that there is no bound to the length of iterated words associated with a single 1.
The number of iterated words with the right branch longer than the left seems to be well balanced, so that (conjecture) the limit of partial sums of this sequence could be o(n).
LINKS
Jean-Christophe Hervé, Table of n, a(n) for n = 2..99990
EXAMPLE
The OK sequence begins as (highlighting the 10th term): 122112122-1-2211211221211... where the iterated word 122-1-221121 of length 10 can be seen around the 10th term; thus a(10) = 10.
CROSSREFS
KEYWORD
sign
AUTHOR
Jean-Christophe Hervé, Oct 30 2014
STATUS
approved