%I #121 Aug 26 2023 08:56:40
%S 1,2,1,1,2,2,2,1,1,2,1,1,2,1,1,2,2,2,1,1,2,2,2,1,1,2,2,2,1,1,2,1,1,2,
%T 1,1,2,2,2,1,1,2,1,1,2,1,1,2,2,2,1,1,2,1,1,2,1,1,2,2,2,1,1,2,2,2,1,1,
%U 2,2,2,1,1,2,1,1,2,1,1,2,2,2,1,1,2,2,2,1,1,2,2,2,1,1,2,1,1,2,1,1,2,2,2,1,1
%N Length of n-th run of identical symbols in the Thue-Morse sequence A010060 (or A001285).
%C It appears that the sequence can be calculated by any of the following methods:
%C (1) Start with 1 and repeatedly replace 1 with 1, 2, 1 and 2 with 1, 2, 2, 2, 1;
%C (2) a(1) = 1, all terms are either 1 or 2 and, for n > 0, a(n) = 1 if the length of the n-th run of 2's is 1; a(n) = 2 if the length of the n-th run of consecutive 2's is 3, with each run of 2's separated by a run of two 1's;
%C (3) replace each 3 in A080426 with 2. - _John W. Layman_, Feb 18 2003
%C Number of representations of n as a sum of Jacobsthal numbers (1 is allowed twice as a part). Partial sums are A003159. With interpolated zeros, g.f. is (Product_{k>=1} (1 + x^A078008(k)))/2. - _Paul Barry_, Dec 09 2004
%C In other words, the consecutive 0's or 1's in A010060 or A010059. - Robin D. Saunders (saunders_robin_d(AT)hotmail.com), Sep 06 2006
%C From _Carlo Carminati_, Feb 25 2011: (Start)
%C The sequence (starting with the second term) can also be calculated by the following method:
%C Apply repeatedly to the string S_0 = [2] the following algorithm: take a string S, double it, if the last figure is 1, just add the last figure to the previous one, if the last figure is greater than one, decrease it by one unit and concatenate a figure 1 at the end. (This algorithm is connected with the interpretation of the sequence as a continued fraction expansion.) (End)
%C This sequence, starting with the second term, happens to be the continued fraction expansion of the biggest cluster point of the set {x in [0,1]: F^k(x) >= x, for all k in N}, where F denotes the Farey map (see A187061). - _Carlo Carminati_, Feb 28 2011
%C Starting with the second term, the fixed point of the substitution 2 -> 211, 1 -> 2. - _Carlo Carminati_, Mar 03 2011
%C It appears that this sequence contains infinitely many distinct palindromic subsequences. - _Alexander R. Povolotsky_, Oct 30 2016
%C From _Michel Dekking_, Feb 13 2019: (Start)
%C Let tau defined by tau(0) = 01, tau(1) = 10 be the Thue-Morse morphism, with fixed point A010060. Consecutive runs in A010060 are 0, 11, 0, 1, 00, 1, 1, ..., which are coded by their lengths 1, 2, 1, 1, 2, ... Under tau^2 consecutive runs are mapped to consecutive runs:
%C tau^2(0) = 0110, tau^2(1) = 1001,
%C tau^2(00) = 01100110, tau^2(11) = 10011001.
%C The reason is that (by definition of a run!) runs of 0's and runs of 1's alternate in the sequence of runs, and this is inherited by the image of these runs under tau^2.
%C Under tau^2 the runs of length 1 are mapped to the sequence 1,2,1 of run lengths, and the runs of length 2 are mapped to the sequence 1,2,2,2,1 of run lengths. This proves John Layman's conjecture number (1): it follows that (a(n)) is fixed point of the morphism alpha
%C alpha: 1 -> 121, 2 -> 12221.
%C Since alpha(1) and alpha(2) are both palindromes, this also proves Alexander Povolotsky's conjecture.
%C (End)
%H N. J. A. Sloane, <a href="/A026465/b026465.txt">Table of n, a(n) for n = 1..10000</a>
%H J.-P. Allouche, Andre Arnold, Jean Berstel, Srecko Brlek, William Jockusch, Simon Plouffe and Bruce E. Sagan, <a href="http://dx.doi.org/10.1016/0012-365X(93)00147-W">A sequence related to that of Thue-Morse</a>, Discrete Math., Vol. 139, No. 1-3 (1995), pp. 455-461.
%H G. Allouche, J.-P. Allouche and J. Shallit, <a href="https://webusers.imj-prg.fr/~jean-paul.allouche/kolam.pdf">Kolam indiens, dessins sur le sable aux îles Vanuatu, courbe de Sierpinski et morphismes de monoïde</a>, Ann. Inst. Fourier (Grenoble), Vol. 56, No. 7 (2006), pp. 2115-2130.
%H Claudio Bonanno, Carlo Carminati, Stefano Isola and Giulio Tiozzo, <a href="http://arxiv.org/abs/1012.2131">Dynamics of continued fractions and kneading sequences of unimodal maps</a>, arXiv:1012.2131 [math.DS], 2010-2012.
%H Srećko Brlek, <a href="http://dx.doi.org/10.1016/0166-218X(92)90274-E">Enumeration of factors in the Thue-Morse word</a>, Discrete Applied Math., Vol. 24, No. 1-3 (1989), pp. 83-96.
%H Julien Cassaigne, <a href="http://dx.doi.org/10.1016/S0304-3975(98)00247-3">Limit values of the recurrence quotient of Sturmian sequences</a>, Theoret. Comput. Sci., Vol. 218, No. 1 (1999), pp. 3-12.
%H Artūras Dubickas, <a href="http://dx.doi.org/10.1016/j.jnt.2005.07.004">On the distance from a rational power to the nearest integer</a>, Journal of Number Theory, Vol. 117, No. 1 (March 2006), pp. 222-239.
%H Artūras Dubickas, <a href="http://dx.doi.org/10.1016/j.disc.2006.08.001">On a sequence related to that of Thue-Morse and its applications</a>, Discrete Math., Vol. 307, No. 9-10 (2007), pp. 1082-1093. MR2292537 (2008b:11086).
%H Cor Kraaikamp, Thomas A. Schmidt and Wolfgang Steiner, <a href="http://arxiv.org/abs/1011.4283">Natural extensions and entropy of alpha-continued fractions</a>, arXiv:1011.4283 [math.DS], 2010-2012.
%H Claude Lenormand, <a href="/A318921/a318921.pdf">Deux transformations sur les mots</a>, Preprint, 5 pages, Nov 17 2003. Apparently unpublished. This is a scanned copy of the version that the author sent to me in 2003. - _N. J. A. Sloane_, Sep 09 2018. See page 2.
%H Kevin Ryde, <a href="/A026465/a026465.gp.txt">PARI/GP Code</a>
%H Jeffrey Shallit, <a href="https://doi.org/10.5802/jtnb.173">Automaticity IV: Sequences, sets, and diversity</a>, J. Théor. Nombres Bordeaux, Vol. 8, No. 2 (1996), pp. 347-367. See page 354.
%F a(1) = 1; for n > 1, a(n) = A003159(n) - A003159(n-1). - _Benoit Cloitre_, May 31 2003
%F G.f.: Product_{k>=1} (1 + x^A001045(k)). - _Paul Barry_, Dec 09 2004
%F Asymptotic mean: lim_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 3/2. - _Amiram Eldar_, Jan 16 2022
%p # From _Carlo Carminati_, Feb 25 2011:
%p ## period-doubling routine:
%p double:=proc(SS)
%p NEW:=[op(S), op(S)]:
%p if op(nops(NEW),NEW)=1
%p then NEW:=[seq(op(j,NEW), j=1..nops(NEW)-2),op(nops(NEW)-1,NEW)+1]:
%p else NEW:=[seq(op(j,NEW), j=1..nops(NEW)-1),op(nops(NEW)-1,NEW)-1,1]:
%p fi:
%p end proc:
%p # 10 loops of the above routine generate the first 1365 terms of the sequence
%p # (except for the initial term):
%p S:=[2]:
%p for j from 1 to 10 do S:=double(S); od:
%p S;
%p # From _N. J. A. Sloane_, Dec 31 2013:
%p S:=[b]; M:=14;
%p for n from 1 to M do T:=subs({b=[b,a,a], a=[b]}, S);
%p S := map(x->op(x),T); od:
%p T:=subs({a=1,b=2},S): T:=[1,op(T)]: [seq(T[n],n=1..40)];
%t Length /@ Split@ Nest[ Flatten@ Join[#, # /. {1 -> 2, 2 -> 1}] &, {1}, 7]
%t NestList[ Flatten[# /. {1 -> {2}, 2 -> {1, 1, 2}}] &, {1}, 7] // Flatten (* _Robert G. Wilson v_, May 20 2014 *)
%o (Haskell)
%o import Data.List (group)
%o a026465 n = a026465_list !! (n-1)
%o a026465_list = map length $ group a010060_list
%o -- _Reinhard Zumkeller_, Jul 15 2014
%o (PARI) See links.
%Y Cf. A010060, A001285, A101615, A026490 (run lengths).
%Y A080426 is an essentially identical sequence with another set of constructions.
%Y Cf. A104248 (bisection odious), A143331 (bisection evil), A003159 (partial sums).
%Y Cf. A187061, A363361 (as continued fraction).
%K nonn,eigen
%O 1,2
%A _Clark Kimberling_
%E Corrected and extended by _John W. Layman_, Feb 18 2003
%E Definition revised by _N. J. A. Sloane_, Dec 30 2013