

A257727


Permutation of natural numbers: a(1) = 1, a(oddprime(n)) = 1 + 2*a(n), a(not_an_oddprime(n)) = 2*a(n1).


4



1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 9, 14, 11, 16, 20, 24, 13, 18, 15, 28, 22, 32, 17, 40, 48, 26, 36, 30, 21, 56, 25, 44, 64, 34, 80, 96, 19, 52, 72, 60, 29, 42, 23, 112, 50, 88, 33, 128, 68, 160, 192, 38, 41, 104, 144, 120, 58, 84, 49, 46, 27, 224, 100, 176, 66, 256, 37, 136, 320, 384, 31, 76, 57, 82, 208, 288, 240, 116, 45
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,2


COMMENTS

Here oddprime(n) = nth odd prime = A065091(n) = A000040(n+1), not_an_oddprime(n) = nth natural number which is not an odd prime = A065090(n).


LINKS

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


FORMULA

a(1) = 1; a(2) = 2; and for n > 2, if A010051(n) = 1 [i.e., when n is a prime], then a(n) = 1 + 2*a(A000720(n)1), otherwise a(n) = 2*a(A062298(n)).
As a composition of other permutations:
a(n) = A246377(A257730(n)).
a(n) = A257725(A257801(n)).


EXAMPLE

For n=2, which is the second natural number >= 1 that is not an odd prime [2 = A065090(2)], we compute 2*a(1) = 2 = a(2).
For n=4, which is A065090(3), we compute 2*a(31) = 2*2 = 4.
For n=5, and 5 is the second odd prime [5 = A065091(2)], thus a(5) = 1 + 2*a(2) = 5.
For n=9, which is the sixth natural number >= 1 not an odd prime (9 = A065090(6)), we compute 2*a(61) = 2*5 = 10.
For n=11, which is the fourth odd prime [11 = A065091(4)], we compute 1 + 2*a(4) = 1 + 2*4 = 9, thus a(11) = 9.


PROG

(Scheme, with memoizing definecmacro)
(definec (A257727 n) (cond ((<= n 2) n) ((= 1 (A010051 n)) (+ 1 (* 2 (A257727 (+ 1 (A000720 n)))))) (else (* 2 (A257727 (A062298 n))))))


CROSSREFS

Inverse: A257728.
Cf. A000720, A010051, A062298, A065090, A065091.
Related or similar permutations: A246377, A246378, A257725, A257730, A257801.
Sequence in context: A229769 A130676 A039227 * A039273 A039164 A263977
Adjacent sequences: A257724 A257725 A257726 * A257728 A257729 A257730


KEYWORD

nonn


AUTHOR

Antti Karttunen, May 09 2015


STATUS

approved



