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”).

A368844
a(n) gives the number of triples of equally spaced 0's in the binary expansion of n (without leading zeros).
3
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 4, 2, 2, 1, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 6, 4, 3, 2, 2, 2, 1, 1, 2, 0, 1, 0, 0, 0, 0, 0, 3, 2, 0, 0, 1, 1, 0
OFFSET
0,17
FORMULA
a(2*n) >= a(n).
a(2*n + 1) = a(n).
EXAMPLE
For n = 277:
- the binary expansion of 277 is "100010101",
- we have the following triples: 000
0 0 0
0 0 0
- so a(277) = 3.
PROG
(PARI) a(n, t = 0, base = 2) = { my (d = digits(n, base), v = 0); for (i = 1, #d-2, if (d[i]==t, forstep (j = i+2, #d, 2, if (d[i]==d[j] && d[i]==d[(i+j)/2], v++; ); ); ); ); return (v); }
(Python)
def A368844(n):
l = len(s:=bin(n)[3:])
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]=='000') # Chai Wah Wu, Jan 10 2024
CROSSREFS
Sequence in context: A304021 A378357 A056974 * A377336 A181563 A056976
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Jan 07 2024
STATUS
approved