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