OFFSET
1,1
COMMENTS
More informally, in binary, the a(k)-th bit of a(n) is set iff the k-th bit of n is set (where the least significant bit has index 1).
For any k >= 0, the restriction of this sequence to the first A007013(k) terms is a self-inverse permutation preserving the Hamming weight; this property can be proven by induction.
This sequence is a self-inverse permutation of the natural numbers.
This sequence has infinitely many fixed points (A300950); for any k >= 0, at least one of 2^k or 2^k + a(2^k) is a fixed point.
LINKS
EXAMPLE
a(3) = a(2^1 + 2^0) = 2^(a(2)-1) + 2^(a(1)-1) = 2^0 + 2^1 = 3.
a(4) = a(2^2) = 2^(a(3)-1) = 2^2 = 4.
a(6) = a(2^2 + 2^1) = 2^(a(3)-1) + 2^(a(2)-1) = 2^2 + 2^0 = 5.
a(42) = a(2^5 + 2^3 + 2^1) = 2^(a(6)-1) + 2^(a(4)-1) + 2^(a(2)-1) = 2^4 + 2^3 + 2^0 = 25.
MATHEMATICA
a[1] = 2; a[2] = 1; a[n_] := a[n] = With[{b = IntegerDigits[n, 2] // Reverse}, Sum[If[b[[i]] == 1, 2^(a[i]-1), 0], {i, Length[b]}]]; Array[a, 100] (* Jean-François Alcover, Mar 17 2018 *)
PROG
(PARI) a(n) = if (n==1, 2, n==2, 1, my (b=Vecrev(binary(n))); sum(i=1, #b, if (b[i], 2^(a(i)-1), 0)))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Mar 16 2018
STATUS
approved