login
In the binary expansion of n, complement bits at even positions and to the right of a 1 (the most significant bit corresponding to position 1).
2

%I #10 Aug 06 2024 16:38:37

%S 0,1,3,2,6,7,4,5,12,13,15,14,8,9,11,10,24,25,26,27,30,31,28,29,16,17,

%T 18,19,22,23,20,21,48,49,51,50,52,53,55,54,60,61,63,62,56,57,59,58,32,

%U 33,35,34,36,37,39,38,44,45,47,46,40,41,43,42,96,97,98,99

%N In the binary expansion of n, complement bits at even positions and to the right of a 1 (the most significant bit corresponding to position 1).

%C This sequence is a self-inverse permutation of the nonnegative integers.

%H Rémy Sigrist, <a href="/A375183/b375183.txt">Table of n, a(n) for n = 0..8191</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F a(floor(n/2)) = floor(a(n)/2).

%e For n = 9: the binary expansion of 9 is "1001": the bit at position 2 (0) sits to the right of a 1 so we complement it, the bit at position 4 (1) sits to the right of a 0 so we keep it; the binary expansion of a(9) is "1101" and a(9) = 13.

%o (PARI) a(n) = { my (b = binary(n)); forstep (k = 2, #b, 2, if (b[k-1], b[k] = 1-b[k];);); fromdigits(b, 2); }

%Y Cf. A063946, A165199, A375184.

%K nonn,base

%O 0,3

%A _Rémy Sigrist_, Aug 03 2024