login
Binary interpretation of the left diagonal of the XOR-triangle with first row generated from the binary expansion of n, with most significant bit given by first row.
7

%I #18 May 16 2020 16:03:06

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

%T 23,22,19,18,17,16,63,62,60,61,59,58,56,57,51,50,48,49,55,54,52,53,42,

%U 43,41,40,46,47,45,44,38,39,37,36,34,35,33,32,127,126,125

%N Binary interpretation of the left diagonal of the XOR-triangle with first row generated from the binary expansion of n, with most significant bit given by first row.

%C This sequence is a self-inverse permutation of the nonnegative numbers, with only two fixed points: a(0) = 0 and a(1) = 1.

%H Rémy Sigrist, <a href="/A334727/b334727.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/X#XOR-triangles">Index entries for sequences related to XOR-triangles</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).

%F abs(a(2*n+1) - a(2*n)) = 1.

%F a(2^k) = 2^(k+1) - 1 for any k >= 0.

%F a(2^k-1) = 2^(k-1) for any k > 0.

%e For n = 42:

%e - the binary expansion of 42 is "101010",

%e - the corresponding XOR-triangle is:

%e 1 0 1 0 1 0

%e 1 1 1 1 1

%e 0 0 0 0

%e 0 0 0

%e 0 0

%e 0

%e - the bits on the left diagonal are: 1, 1, 0, 0, 0, 0,

%e - so a(42) = 2^5 + 2^4 = 48.

%o (PARI) a(n) = { my (v=0); forstep (x=#binary(n)-1, 0, -1, if (bittest(n, x), v+=2^x;); n=bitxor(n, n\2)); return (v) }

%Y See A334595 for a similar sequence.

%K nonn,base

%O 0,3

%A _Rémy Sigrist_, May 09 2020