login
Lengths of successive runs of 1's in the Thue-Morse sequence A010060.
5

%I #24 Jan 30 2025 14:07:45

%S 2,1,2,1,2,1,1,2,2,1,2,1,2,2,1,1,2,1,2,1,2,1,1,2,2,1,1,2,1,2,1,2,2,1,

%T 2,1,2,1,1,2,2,1,2,1,2,2,1,1,2,1,2,1,2,2,1,2,1,2,1,1,2,2,1,1,2,1,2,1,

%U 2,1,1,2,2,1,2,1,2,2,1,1,2,1,2,1,2,1,1,2,2,1,1,2,1,2,1,2,2,1,2,1,2,1,1,2,2

%N Lengths of successive runs of 1's in the Thue-Morse sequence A010060.

%C Also lengths of successive runs of 0's in the Thue-Morse sequence A010059.

%C Also lengths of successive runs of 2's in the Thue-Morse sequence A001285.

%C A variant of A036577, suggested by p. 4421 of Grytczuk.

%H Ray Chandler, <a href="/A104248/b104248.txt">Table of n, a(n) for n=1..10922</a>

%H Jaroslaw Grytczuk, <a href="http://dx.doi.org/10.1016/j.disc.2007.08.039">Thue type problems for graphs, points and numbers</a>, Discrete Math., 308 (2008), 4419-4429.

%F a(n) = A026465(2n).

%e A010060 begins 011010011001011010010110011010011... so the runs of 1's have lengths 2 1 2 1 2 1 1 2 2 1 2 1 2 2 1 1 2 1 ...

%t Map[Length,Most[Split[ThueMorse[Range[500]]]][[;;;;2]]] (* _Paolo Xausa_, Dec 19 2023 *)

%t Length/@DeleteCases[Split[ThueMorse[Range[450]]],_?(#[[1]]==0&)] (* _Harvey P. Dale_, Nov 09 2024 *)

%o (Python)

%o def A104248(n):

%o def iterfun(f,n=0):

%o m, k = n, f(n)

%o while m != k: m, k = k, f(k)

%o return m

%o def f(x):

%o c, s = x, bin(x)[2:]

%o l = len(s)

%o for i in range(l&1^1,l,2):

%o c -= int(s[i])+int('0'+s[:i],2)

%o return c

%o return iterfun(lambda x:f(x)+(n<<1),n<<1)-iterfun(lambda x:f(x)+(n<<1)-1,(n<<1)-1) # _Chai Wah Wu_, Jan 30 2025

%Y Cf. A010060, A036577, A143331.

%Y Cf. A001285, A010059, A026465.

%K nonn,easy

%O 1,1

%A _N. J. A. Sloane_, Aug 05 2008

%E Edited and extended by _Ray Chandler_, Aug 08 2008