OFFSET
0,3
LINKS
Kevin Ryde, Table of n, a(n) for n = 0..8192
FORMULA
EXAMPLE
n = 172 = binary 10101100;
a(n) = 252 = binary 11111100.
PROG
(PARI) a(n) = if(n, 2<<logint(n, 2) - 1<<valuation(n, 2), 0);
(Python) def a(n): return (1<<n.bit_length()) - (n&-n) if n else 0
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Kevin Ryde, Jan 13 2021
STATUS
approved