login
Permutation of natural numbers: a(1)=1; a(oddprime(n)) = prime(a(n)), a(not_an_oddprime(n)) = composite(a(n-1)).
5

%I #13 May 10 2015 10:59:59

%S 1,4,2,9,7,6,3,16,14,12,23,8,17,26,24,21,13,35,5,15,27,39,53,36,33,22,

%T 51,10,43,25,37,40,56,75,52,49,83,34,72,18,19,62,59,38,54,57,101,78,

%U 102,74,69,114,89,50,98,28,30,86,73,82,41,55,76,80,134,106,149,135,100,94,11,150,47,120,70,130,42,45,103,117,99,112,167,58,77

%N Permutation of natural numbers: a(1)=1; a(oddprime(n)) = prime(a(n)), a(not_an_oddprime(n)) = composite(a(n-1)).

%C Here composite(n) = n-th composite = A002808(n), prime(n) = n-th prime = A000040(n), oddprime(n) = n-th odd prime = A065091(n) = A000040(n+1), not_an_oddprime(n) = n-th natural number which is not an odd prime = A065090(n).

%H Antti Karttunen, <a href="/A257730/b257730.txt">Table of n, a(n) for n = 1..10000</a>

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

%F a(1) = 1; if A000035(n) = 1 and A010051(n) = 1 [i.e., when n is an odd prime], then a(n) = A000040(a(A000720(n)-1)), otherwise a(n) = A002808(a(A062298(n))). [Here A062298(n) gives the index of n among numbers larger than 1 which are not odd primes, 1 for 2, 2 for 4, 3 for 6, etc.]

%F As a composition of other permutations:

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

%F a(n) = A257732(A257801(n)).

%o (Scheme, with memoizing definec-macro)

%o (definec (A257730 n) (cond ((<= n 1) n) ((and (odd? n) (= 1 (A010051 n))) (A000040 (A257730 (+ -1 (A000720 n))))) (else (A002808 (A257730 (A062298 n))))))

%o ;; Alternatively, by composing other permutations:

%o (define (A257730 n) (A246378 (A257727 n)))

%Y Inverse: A257729.

%Y Cf. A000040, A000720, A002808, A010051, A062298, A065090, A065091.

%Y Related or similar permutations: A246378, A257727, A257732, A257801, A236854.

%K nonn

%O 1,2

%A _Antti Karttunen_, May 09 2015