OFFSET
0,3
COMMENTS
a(n) obeys the recurrences a(2n) = a(n), a(4n+1) = 2a(n) + a(2n+1), a(8n+3) = 4a(n) + a(4n+3), and a(8n+7) = -2a(n) + a(2n+1) + 2a(4n+3).
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8192
EXAMPLE
a(15) = 10, because if we delete the 2nd and 4th bits of 1111, we get 1010.
PROG
(PARI) a(n) = my (b=binary(n), o=0); for (k=1, #b, if (b[k], b[k]=o++%2)); fromdigits(b, 2) \\ Rémy Sigrist, Feb 19 2020
(Python)
def a(n):
switch, b, out = False, bin(n)[2:], ""
for bi in b:
if bi == "0": out += "0"
else: out += "0" if switch else "1"; switch = not switch
return int(out, 2)
print([a(n) for n in range(91)]) # Michael S. Branicky, Jul 15 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Jeffrey Shallit, Dec 06 2015
STATUS
approved