login
A257731
Permutation of natural numbers: a(1) = 1, a(prime(n)) = lucky(1+a(n)), a(composite(n)) = unlucky(a(n)), where prime(n) = n-th prime number A000040, composite(n) = n-th composite number A002808 and lucky = A000959, unlucky = A050505.
6
1, 3, 9, 2, 33, 5, 7, 14, 4, 45, 163, 8, 15, 11, 20, 6, 25, 59, 63, 203, 12, 22, 13, 17, 28, 10, 35, 78, 235, 83, 1093, 251, 18, 30, 19, 24, 31, 39, 16, 47, 67, 101, 43, 290, 107, 1283, 87, 309, 26, 41, 27, 34, 21, 42, 53, 23, 61, 88, 115, 128, 321, 57, 354, 137, 1499, 112, 349, 376, 36, 55, 1401, 38, 49, 46, 29, 56, 70, 32, 99, 81
OFFSET
1,2
FORMULA
a(1) = 1; for n > 1: if A010051(n) = 1 [i.e., if n is a prime], then a(n) = A000959(1+a(A000720(n))), otherwise a(n) = A050505(a(A065855(n))).
As a composition of other permutations:
a(n) = A257726(A246377(n)).
a(n) = A257733(A255421(n)).
PROG
(Scheme, with memoization-macro definec)
(definec (A257731 n) (cond ((= 1 n) n) ((= 1 (A010051 n)) (A000959 (+ 1 (A257731 (A000720 n))))) (else (A050505 (A257731 (A065855 n))))))
;; Alternatively, by composing other permutations:
(define (A257731 n) (A257726 (A246377 n)))
(define (A257731 n) (A257733 (A255421 n)))
CROSSREFS
Inverse: A257732.
Related or similar permutations: A246377, A255421, A257726, A257733.
Cf. also A032600, A255553, A255554.
Differs from A257733 for the first time at n=19, where a(19) = 63, while A257733(19) = 203.
Sequence in context: A246379 A303941 A176885 * A257733 A098323 A225460
KEYWORD
nonn
AUTHOR
Antti Karttunen, May 06 2015
STATUS
approved