cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A143331 Lengths of successive runs of 0's in the Thue-Morse sequence A010060.

This page as a plain text file.
%I A143331 #16 Jan 30 2025 15:28:15
%S A143331 1,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,2,1,1,2,2,1,2,1,
%T A143331 2,2,1,1,2,1,2,1,2,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,
%U A143331 1,1,2,1,2,1,2,2,1,2,1,2,1,1,2,2,1,1,2,1,2,1,2,1,1,2,2,1,2,1,2,2,1,1,2,1,2
%N A143331 Lengths of successive runs of 0's in the Thue-Morse sequence A010060.
%C A143331 Also lengths of successive runs of 1's in the Thue-Morse sequence A010059.
%C A143331 Also lengths of successive runs of 1's in the Thue-Morse sequence A001285.
%H A143331 Ray Chandler, <a href="/A143331/b143331.txt">Table of n, a(n) for n=1..10923</a>
%F A143331 a(n) = A026465(2n-1).
%e A143331 A010060 begins 011010011001011010010110011010011... so the runs of 0's have lengths 1 1 2 2 1 1 2 1 2 1 2 2 1 2 1 2 1 1 ...
%t A143331 Map[Length,Most[Split[ThueMorse[Range[0,500]]]][[;;;;2]]] (* _Paolo Xausa_, Dec 19 2023 *)
%o A143331 (Python)
%o A143331 def A143331(n):
%o A143331     if n==1: return 1
%o A143331     def iterfun(f,n=0):
%o A143331         m, k = n, f(n)
%o A143331         while m != k: m, k = k, f(k)
%o A143331         return m
%o A143331     def f(x):
%o A143331         c, s = x, bin(x)[2:]
%o A143331         l = len(s)
%o A143331         for i in range(l&1^1,l,2):
%o A143331             c -= int(s[i])+int('0'+s[:i],2)
%o A143331         return c
%o A143331     return iterfun(lambda x:f(x)+(n<<1)-1,(n<<1)-1)-iterfun(lambda x:f(x)+(n-1<<1),(n-1<<1)) # _Chai Wah Wu_, Jan 30 2025
%Y A143331 Cf. A010060, A104248.
%Y A143331 Cf. A001285, A010059, A026465.
%K A143331 nonn,easy
%O A143331 1,3
%A A143331 _Ray Chandler_, Aug 08 2008