OFFSET
0,2
COMMENTS
This sequence corresponds to the main diagonal of A295653.
To compute a(n):
- consider the binary expansion of n: Sum_{k >= 0} b_k * 2^k,
- and the positions of zeros in this binary expansion: {z_k, k >= 0},
- then a(n) = Sum_{k >= 0} b_k * 2^z(k).
LINKS
FORMULA
EXAMPLE
For n = 43:
- the binary expansion of 43 is "... 0 0 0 0 1 0 1 0 1 1"
- so the binary expansion of a(43) is "... 1 0 1 0(0)1(0)1(0 0)",
- and a(43) = 660.
PROG
(PARI) a(n) = { my (m=n, v=0); for (e=0, oo, if (n==0, return (v), !bittest(m, e), if (n%2, v+=2^e; ); n\=2)) }
(Python)
def a(n):
b = bin(n)[2:][::-1]
z = [k for k, bk in enumerate(b+'0'*(len(b)-b.count('0'))) if bk=='0']
return sum(int(bk)*2**zk for bk, zk in zip(b, z))
print([a(n) for n in range(56)]) # Michael S. Branicky, Apr 21 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 14 2022
STATUS
approved