login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A257730
Permutation of natural numbers: a(1)=1; a(oddprime(n)) = prime(a(n)), a(not_an_oddprime(n)) = composite(a(n-1)).
5
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, 51, 10, 43, 25, 37, 40, 56, 75, 52, 49, 83, 34, 72, 18, 19, 62, 59, 38, 54, 57, 101, 78, 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
OFFSET
1,2
COMMENTS
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).
FORMULA
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.]
As a composition of other permutations:
a(n) = A246378(A257727(n)).
a(n) = A257732(A257801(n)).
PROG
(Scheme, with memoizing definec-macro)
(definec (A257730 n) (cond ((<= n 1) n) ((and (odd? n) (= 1 (A010051 n))) (A000040 (A257730 (+ -1 (A000720 n))))) (else (A002808 (A257730 (A062298 n))))))
;; Alternatively, by composing other permutations:
(define (A257730 n) (A246378 (A257727 n)))
CROSSREFS
Inverse: A257729.
Related or similar permutations: A246378, A257727, A257732, A257801, A236854.
Sequence in context: A351164 A101690 A213781 * A246378 A260422 A237126
KEYWORD
nonn
AUTHOR
Antti Karttunen, May 09 2015
STATUS
approved