login
A368842
a(n) gives the number of triples of equally spaced equal digits in the binary expansion of n (without leading zeros).
4
0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 2, 2, 1, 0, 0, 0, 1, 0, 2, 1, 0, 0, 0, 1, 2, 2, 4, 4, 2, 2, 1, 0, 0, 0, 1, 2, 0, 2, 1, 0, 0, 2, 3, 2, 1, 0, 0, 0, 1, 0, 2, 2, 1, 2, 2, 2, 3, 4, 6, 6, 4, 3, 2, 2, 2, 1, 2, 2, 1, 1, 1, 0, 1, 1, 3, 3, 2, 0, 0, 2, 3, 1
OFFSET
0,16
COMMENTS
This sequence diverges to infinity by Van der Waerden's theorem.
A000225 \ {1, 3} corresponds to indices of records.
FORMULA
a(2^k) = A002620(k - 1) for any k > 0.
a(2^k - 1) = A002620(k - 1) for any k > 0.
a(n) = A368843(n) + A368844(n).
a(floor(n/2)) <= a(n).
EXAMPLE
For n = 277:
- the binary expansion of 277 is "100010101",
- we have the following triples: 1 1 1
000
0 0 0
0 0 0
1 1 1
- so a(277) = 5.
PROG
(PARI) a(n, base=2) = { my (d = digits(n, base), v = 0); for (i = 1, #d-2, forstep (j = i+2, #d, 2, if (d[i]==d[j] && d[i]==d[(i+j)/2], v++; ); ); ); return (v); }
(Python)
def A368842(n):
l = len(s:=bin(n)[2:])
return sum(1 for i in range(l-2) for j in range(1, l-i+1>>1) if s[i:i+(j<<1)+1:j] in {'000', '111'}) # Chai Wah Wu, Jan 10 2024
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Jan 07 2024
STATUS
approved