

A257731


Permutation of natural numbers: a(1) = 1, a(prime(n)) = lucky(1+a(n)), a(composite(n)) = unlucky(a(n)), where prime(n) = nth prime number A000040, composite(n) = nth 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
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,2


LINKS

Antti Karttunen, Table of n, a(n) for n = 1..6185
Index entries for sequences that are permutations of the natural numbers


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 memoizationmacro 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.
Cf. A000040, A000720, A000959, A002808, A010051, A050505, A065855.
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
Adjacent sequences: A257728 A257729 A257730 * A257732 A257733 A257734


KEYWORD

nonn


AUTHOR

Antti Karttunen, May 06 2015


STATUS

approved



