A265263 Change every other 1 bit in binary expansion of n to 0.
0, 1, 2, 2, 4, 4, 4, 5, 8, 8, 8, 9, 8, 9, 10, 10, 16, 16, 16, 17, 16, 17, 18, 18, 16, 17, 18, 18, 20, 20, 20, 21, 32, 32, 32, 33, 32, 33, 34, 34, 32, 33, 34, 34, 36, 36, 36, 37, 32, 33, 34, 34, 36, 36, 36, 37, 40, 40, 40, 41, 40, 41, 42, 42, 64, 64, 64, 65, 64, 65, 66, 66, 64, 65, 66, 66, 68, 68, 68, 69, 64, 65, 66, 66, 68, 68, 68, 69, 72, 72, 72
Offset: 0
Examples
a(15) = 10, because if we delete the 2nd and 4th bits of 1111, we get 1010.
Links
- Rémy Sigrist, Table of n, a(n) for n = 0..8192
Programs
-
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
Comments