login
Inverse permutation to A302781.
3

%I #9 Mar 22 2022 00:12:09

%S 0,1,3,15,5,2,21,14,63,6,255,12,85,20,4,341,1023,62,4095,10,22,254,

%T 1365,13,5461,86,60,16,16383,7,65535,340,252,1022,26,48,21845,4094,84,

%U 9,87381,23,262143,240,58,1366,1048575,342,349525,5460,1020,90,1398101,61,250,19,4092,16382,4194303,11,16777215,65534,42

%N Inverse permutation to A302781.

%H Antti Karttunen, <a href="/A302782/b302782.txt">Table of n, a(n) for n = 1..8192</a>

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

%F a(n) = A302845(A052331(n)).

%o (PARI)

%o up_to = 8192;

%o v050376 = vector(up_to);

%o ispow2(n) = (n && !bitand(n,n-1));

%o i = 0; for(n=1,oo,if(ispow2(isprimepower(n)), i++; v050376[i] = n); if(i == up_to,break));

%o A052331(n) = { my(s=0,e); while(n > 1, fordiv(n, d, if(((n/d)>1)&&ispow2(isprimepower(n/d)), e = vecsearch(v050376, n/d); if(!e, print("v050376 too short!"); return(1/0)); s += 2^(e-1); n = d; break))); (s); };

%o A006068(n)= { my(s=1, ns); while(1, ns = n >> s; if(0==ns, break()); n = bitxor(n, ns); s <<= 1; ); return (n); } \\ From A006068

%o A057300(n) = { my(t=1,s=0); while(n>0, if(1==(n%4),n++,if(2==(n%4),n--)); s += (n%4)*t; n >>= 2; t <<= 2); (s); };

%o A163355(n) = if(!n,n,my(i = (#binary(n)-1)\2, f = 4^i, d = (n\f)%4, r = (n%f)); if(((1==d)&&!(i%2))||((2==d)&&(i%2)), f+A163355(A057300(r)), if(3==d,f+f+A163355(A057300(r)), (3*f)+A163355(f-1-r))));

%o A302845(n) = A163355(A006068(A006068(n)));

%o A302782(n) = A302845(A052331(n));

%Y Cf. A302781 (inverse).

%Y Cf. A006068, A052331, A163355, A302845.

%K nonn

%O 1,3

%A _Antti Karttunen_, Apr 14 2018