%I
%S 0,0,4,2,0,5,0,0,10,0,0,4,2,0,2,4,0,0,8,0,2,2,0,8,0,0,4,2,0,2,
%T 2,0,5,0,0,14,0,0,4,2,0,5,0,0,5,0,2,2,0,2,4,0,0,24,0,0,4,2,0,5,0,
%U 0,10,0,0,4,2,0,2,2,0,5,0,0,5,0,2,4,0,0,38,0,0,4,2,0,5
%N Length of full iterated word (direct branch and reverse branch) of the Kolakoski sequence A000002 initiated at A000002(n). If the reverse branch is longer than the direct branch, the total length is counted negatively: if A000002(n) = 2, a(n) = 0; if A000002(n) = 1, a(n) = (ld+lr1)*sign(ldlr) with ld = max { k  A000002(ni+1) = A000002(i), 0<i<=k } and lr = max { k  A000002(ni+1) = A000002(i), 0<i<=k }.
%C 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., 1221221121. 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).
%C 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 > 21221 > 1221221121 > ... (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.
%C 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 112211.
%C 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)12(1) or (1)1221(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.
%C 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).
%H JeanChristophe HervĂ©, <a href="/A249507/b249507.txt">Table of n, a(n) for n = 2..99990</a>
%F a(n) = (A249093(n) + A249094(n)  min(1, A249093(n))) * sign(A249093(n)  A249094(n)).
%e The OK sequence begins as (highlighting the 10th term): 12211212212211211221211... where the iterated word 1221221121 of length 10 can be seen around the 10th term; thus a(10) = 10.
%Y Cf. A000002, A054351, A054352, A249093, A249094, A249508.
%K sign
%O 2,3
%A _JeanChristophe HervĂ©_, Oct 30 2014
