The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A368857 a(n) gives the maximum number of equally spaced equal digits in the binary expansion of n (without leading zeros). 2

%I #10 Jan 10 2024 13:54:41

%S 0,1,1,2,2,2,2,3,3,2,2,2,2,2,3,4,4,3,2,2,2,3,2,3,3,2,2,2,3,3,4,5,5,4,

%T 3,3,2,2,2,3,3,2,3,3,2,2,3,4,4,3,2,2,2,3,2,3,3,3,3,3,4,4,5,6,6,5,4,4,

%U 3,3,3,3,3,3,3,3,2,3,3,4,4,3,2,2,3,4,3

%N a(n) gives the maximum number of equally spaced equal digits in the binary expansion of n (without leading zeros).

%C This sequence diverges to infinity by Van der Waerden's theorem.

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F a(2^k) = k for any k > 0.

%F a(2^k - 1) = k for any k >= 0.

%F a(2*n) >= a(n).

%o (PARI) a(n, base = 2) = { my (b = digits(n, base), v = if (n, 1, 0)); for (i = 1, #b-1, for (j = i+1, #b, if (b[i]==b[j], my (d = j-i, k = j); while (k + d <= #b && b[k + d]==b[i], k += d;); v = max(v, 1 + (k-i) / d);););); return (v); }

%o (Python)

%o def A368857(n):

%o if n == 0: return 0

%o l = len(s:=bin(n)[2:])

%o return 1+max((k-1-i)//j for i in range(l) for j in range(1,l-i+3>>1) for k in range(i+1,l+1,j) if len(set(s[i:k:j]))==1) # _Chai Wah Wu_, Jan 10 2024

%Y Cf. A368841.

%K nonn,base

%O 0,4

%A _Rémy Sigrist_, Jan 08 2024

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 16 12:34 EDT 2024. Contains 373429 sequences. (Running on oeis4.)