%I #24 Apr 05 2018 20:32:54
%S 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,27,22,23,24,25,26,
%T 21,28,29,30,31,32,45,34,35,36,37,38,33,40,41,54,43,44,81,46,47,48,49,
%U 50,75,52,53,42,125,56,63,58,59,60,61,62,39,64,55,90,67,68,135,70,71,72,73,74,51,76,77,66,79,80,99,82,83
%N Permutation of natural numbers: a(1) = 1, a(n) = A246278(A055396(n), a(A078898(n))).
%H Antti Karttunen, <a href="/A250246/b250246.txt">Table of n, a(n) for n = 1..16384</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F a(1) = 1, a(n) = A246278(A055396(n), a(A078898(n))).
%F a(1) = 1, a(2n) = 2*a(n), a(2n+1) = A003961(a(A250470(2n+1))). - _Antti Karttunen_, Jan 18 2015 - Instead of A250470, one may use A268674 in above formula. - _Antti Karttunen_, Apr 01 2018
%F As a composition of related permutations:
%F a(n) = A163511(A252756(n)).
%F Other identities. For all n >= 1:
%F a(n) = a(2n)/2. [The even bisection halved gives the sequence back.]
%F A020639(a(n)) = A020639(n) and A055396(a(n)) = A055396(n). [Preserves the smallest prime factor of n].
%F A001221(a(n)) = A302041(n).
%F A001222(a(n)) = A253557(n).
%F A008683(a(n)) = A302050(n).
%F A000005(a(n)) = A302051(n)
%F A010052(a(n)) = A302052(n), for n >= 1.
%F A056239(a(n)) = A302039(n).
%o (PARI)
%o up_to = 16384;
%o ordinal_transform(invec) = { my(om = Map(), outvec = vector(length(invec)), pt); for(i=1, length(invec), if(mapisdefined(om,invec[i]), pt = mapget(om, invec[i]), pt = 0); outvec[i] = (1+pt); mapput(om,invec[i],(1+pt))); outvec; };
%o A020639(n) = if(n>1, if(n>n=factor(n, 0)[1, 1], n, factor(n)[1, 1]), 1); \\ From A020639
%o A055396(n) = if(1==n,0,primepi(A020639(n)));
%o v078898 = ordinal_transform(vector(up_to,n,A020639(n)));
%o A078898(n) = v078898[n];
%o A003961(n) = my(f = factor(n)); for (i=1, #f~, f[i, 1] = nextprime(f[i, 1]+1)); factorback(f); \\ From A003961
%o A250246(n) = if(1==n,n,my(k = 2*A250246(A078898(n)), r = A055396(n)); if(1==r, k, while(r>1, k = A003961(k); r--); (k))); \\ _Antti Karttunen_, Apr 01 2018
%o (Scheme, with memoizing-macro definec from _Antti Karttunen_'s IntSeq-library, three alternative definitions)
%o (definec (A250246 n) (cond ((<= n 1) n) (else (A246278bi (A055396 n) (A250246 (A078898 n)))))) ;; Code for A246278bi given in A246278
%o (definec (A250246 n) (cond ((<= n 1) n) ((even? n) (* 2 (A250246 (/ n 2)))) (else (A003961 (A250246 (A250470 n))))))
%o (define (A250246 n) (A163511 (A252756 n)))
%Y Inverse: A250245.
%Y Other similar permutations: A250243, A250248, A250250, A163511, A252756.
%Y Cf. A003961, A005843, A020639, A055396, A078898, A246278, A250470, A268674, A278524, A302042, A302046.
%Y Differs from the "vanilla version" A249818 for the first time at n=42, where a(42) = 54, while A249818(42) = 42.
%Y Differs from A250250 for the first time at n=73, where a(73) = 73, while A250250(73) = 103.
%K nonn
%O 1,2
%A _Antti Karttunen_, Nov 17 2014