login
Permutation of natural numbers: a(1) = 0, a(2) = 1, and for n > 1, a(2n) = nthcomposite(a(n)), a(2n-1) = nthprime(a(A064989(2n-1))), where nthprime = A000040, nthcomposite = A002808, and A064989(n) shifts the prime factorization of n one step towards smaller primes.
6

%I #9 Sep 01 2014 11:47:59

%S 0,1,2,4,3,6,5,9,7,8,11,12,31,10,13,16,127,14,709,15,19,20,5381,21,17,

%T 46,23,18,52711,22,648391,26,29,166,41,24,9737333,858,71,25,174440041,

%U 30,3657500101,32,37,6186

%N Permutation of natural numbers: a(1) = 0, a(2) = 1, and for n > 1, a(2n) = nthcomposite(a(n)), a(2n-1) = nthprime(a(A064989(2n-1))), where nthprime = A000040, nthcomposite = A002808, and A064989(n) shifts the prime factorization of n one step towards smaller primes.

%C Note the indexing: the domain starts from 1, while the range includes also zero.

%C Has an infinite number of infinite cycles. See comments at A246681.

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

%F a(1) = 0, a(2) = 1, and for n > 1, a(2n) = nthcomposite(a(n)), a(2n-1) = nthprime(a(A064989(2n-1))), where nthprime = A000040, nthcomposite = A002808, and A064989(n) shifts the prime factorization of n one step towards smaller primes.

%F As a composition of related permutations:

%F a(n) = A246378(A243071(n)).

%F Other identities.

%F For all n >= 1 the following holds:

%F a(A000040(n)) = A007097(n-1). [Maps primes to the iterates of primes].

%F A049076(a(A000040(n))) = n. [Follows from above].

%F For all n > 1 the following holds:

%F A010051(a(n)) = A000035(n). [Maps odd numbers larger than one to primes, and even numbers to composites, in some order. Permutations A246378 & A246380 have the same property].

%o (PARI)

%o default(primelimit,(2^31)+(2^30));

%o A002808(n) = { my(k=-1); while( -n + n += -k + k=primepi(n), ); n }; \\ This function from _M. F. Hasler_

%o A064989(n) = {my(f); f = factor(n); if((n>1 && f[1,1]==2), f[1,2] = 0); for (i=1, #f~, f[i,1] = precprime(f[i,1]-1)); factorback(f)};

%o A246682(n) = if(n < 3, n-1, if(!(n%2), A002808(A246682(n/2)), prime(A246682(A064989(n)))));

%o for(n=1, 46, write("b246682.txt", n, " ", A246682(n)));

%o (Scheme, two variants)

%o (definec (A246682 n) (cond ((<= n 2) (- n 1)) ((even? n) (A002808 (A246682 (/ n 2)))) (else (A000040 (A246682 (A064989 n))))))

%o (define (A246682 n) (A246378 (A243071 n)))

%Y Inverse: A246681.

%Y Similar or related permutations: A246376, A246378, A243071, A246368, A064216, A246380.

%Y Cf. A000035, A000040, A002808, A007097, A010051, A064989, A049076, A078442.

%K nonn

%O 1,3

%A _Antti Karttunen_, Sep 01 2014