login
A257801
Permutation of natural numbers: a(1)=1; a(oddprime(n)) = lucky(1+a(n)), a(not_an_oddprime(n)) = unlucky(a(n-1)).
5
1, 2, 3, 4, 7, 5, 9, 6, 11, 8, 13, 14, 25, 10, 17, 12, 15, 19, 33, 20, 35, 16, 21, 24, 18, 22, 27, 45, 43, 28, 31, 47, 23, 29, 34, 26, 51, 30, 38, 59, 63, 57, 115, 39, 42, 61, 37, 32, 40, 46, 36, 66, 73, 41, 52, 78, 83, 76, 49, 146, 67, 53, 56, 81, 50, 44, 79, 54, 60, 48, 163, 86, 87, 95, 55, 68, 101, 107, 171, 98, 64
OFFSET
1,2
COMMENTS
Here lucky(n) = n-th lucky number = A000959(n), unlucky(n) = n-th unlucky number = A050505(n), oddprime(n) = n-th odd prime = A065091(n), not_an_oddprime(n) = n-th natural number which is not an odd prime = A065090(n).
FORMULA
a(1) = 1; a(2) = 2; if A010051(n) = 1 [i.e., when n is an (odd) prime] then a(n) = A000959(1+a(A000720(n)-1)), otherwise a(n) = A050505(a(A062298(n))).
As a composition of other permutations:
a(n) = A257726(A257727(n)).
a(n) = A257731(A257730(n)).
PROG
(Scheme, with memoizing definec-macro)
(definec (A257801 n) (cond ((<= n 2) n) ((= 1 (A010051 n)) (A000959 (+ 1 (A257801 (+ -1 (A000720 n)))))) (else (A050505 (A257801 (A062298 n))))))
;; Alternatively, by composing other permutations:
(define (A257801 n) (A257726 (A257727 n)))
CROSSREFS
Inverse: A257802.
Related or similar permutations: A257726, A257727, A257730, A257731.
Sequence in context: A357578 A125150 A265901 * A257726 A183089 A191544
KEYWORD
nonn
AUTHOR
Antti Karttunen, May 09 2015
STATUS
approved