login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A368857
a(n) gives the maximum number of equally spaced equal digits in the binary expansion of n (without leading zeros).
2
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, 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, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 4, 4, 3, 2, 2, 3, 4, 3
OFFSET
0,4
COMMENTS
This sequence diverges to infinity by Van der Waerden's theorem.
FORMULA
a(2^k) = k for any k > 0.
a(2^k - 1) = k for any k >= 0.
a(2*n) >= a(n).
PROG
(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); }
(Python)
def A368857(n):
if n == 0: return 0
l = len(s:=bin(n)[2:])
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
CROSSREFS
Cf. A368841.
Sequence in context: A292137 A292138 A322665 * A273632 A347387 A196046
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jan 08 2024
STATUS
approved