OFFSET
1,2
COMMENTS
k is uniquely determined by finding the power of two for which k = 2^x - n has wt(k) = n.
Terms are not always increasing, since the number of 0 bits in n-1 reduces k.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..1000
FORMULA
EXAMPLE
For n = 4, 60 in binary is 111100, which has sum of digits of 4, and 60 + 4 = 64, a power of two.
For n = 5, 59 in binary is 111011, which has sum of digits of 5, and 59 + 5 = 64.
MAPLE
a:= n-> 2^(n+add(i, i=Bits[Split](n-1)))-n:
seq(a(n), n=1..32); # Alois P. Heinz, Jul 05 2024
PROG
(Python)
def a(n):
return (1 << (n + (n-1).bit_count())) - n
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Steven Reyes, Jul 05 2024
STATUS
approved