%I #16 Oct 01 2023 07:38:29
%S 1,3,2,5,7,6,4,9,11,13,15,10,14,12,8,17,19,21,23,25,27,29,31,18,22,26,
%T 30,20,28,24,16,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,34,38,
%U 42,46,50,54,58,62,36,44,52,60,40,56,48,32,65,67,69,71
%N Inverse permutation to A316385.
%H Rémy Sigrist, <a href="/A316472/b316472.txt">Table of n, a(n) for n = 1..8191</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F a(n) = (2*b(n) + 1)*2^(L(n) - L(b(n)) - 1) where b(n) = A053645(A153142(n)) and where L(n) = A000523(n) for n > 0 with L(0) = -1. - _Mikhail Kurkov_, Sep 09 2023
%e A316385(42) = 50 hence a(50) = 42.
%o (PARI) b1(n) = my(b=binary(n)); fromdigits(concat(b[1], Vecrev(vector(#b-1, k, b[k+1]))), 2); \\ A059893
%o b2(n) = if(n < 2, n, if((n + 1) == 2^logint(n + 1, 2), (n + 1) / 2, n + 1)) \\ A153152
%o a(n) = my(A = 2^logint(n, 2), B = b1(b2(b1(n))) - A); (2 * B + 1) * A / 2 ^ (if(B == 0, -1, logint(B, 2)) + 1) \\ _Mikhail Kurkov_, Sep 09 2023
%Y Cf. A000523, A053645, A059893, A153142, A316385.
%K nonn,base
%O 1,2
%A _Rémy Sigrist_, Jul 04 2018
|