OFFSET
0,3
COMMENTS
This sequence is a permutation of the nonnegative integers with inverse A371975.
LINKS
EXAMPLE
For n = 42: the binary expansion of 42 is "101010":
b_1 b_2 b_3 b_4 b_5 b_6
1 0 1 0 1 0
c_1 = 1 = 1 mod 2
c_2 = 1 + 0 = 1 mod 2
c_3 = 1 + 1 = 0 mod 2
c_4 = 1 + 0 = 1 mod 2
c_5 = 1 + 1 + 1 = 1 mod 2
c_6 = 1 + 0 + 1 + 0 + 1 + 0 = 1 mod 2
- so the binary expansion of a(42) is "110111", and a(42) = 55.
PROG
(PARI) a(n) = { my (b = binary(n), c = vector(#b)); for (k = 1, #c, forstep (i = 1, #b, #b+1-k, c[k] += b[i]; ); ); fromdigits(c % 2, 2); }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 14 2024
STATUS
approved