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”).

A246378
Permutation of natural numbers: a(1) = 1, a(2n) = nthcomposite(a(n)), a(2n+1) = nthprime(a(n)), where nthcomposite = A002808, nthprime = A000040.
17
1, 4, 2, 9, 7, 6, 3, 16, 23, 14, 17, 12, 13, 8, 5, 26, 53, 35, 83, 24, 43, 27, 59, 21, 37, 22, 41, 15, 19, 10, 11, 39, 101, 75, 241, 51, 149, 114, 431, 36, 89, 62, 191, 40, 103, 82, 277, 33, 73, 54, 157, 34, 79, 58, 179, 25, 47, 30, 67, 18, 29, 20, 31, 56, 167, 134, 547, 102, 379, 304, 1523, 72, 233
OFFSET
1,2
COMMENTS
Contains an infinite number of infinite cycles. See comments at A246377.
FORMULA
a(1) = 1, a(2n) = nthcomposite(a(n)), a(2n+1) = nthprime(a(n)), where nthcomposite = A002808, nthprime = A000040.
As a composition of related permutations:
a(n) = A227413(A054429(n)).
a(n) = A236854(A227413(n)).
a(n) = A246380(A246375(n)).
a(n) = A246682(A163511(n)). [For n >= 1].
Other identities. For all n > 1 the following holds:
A010051(a(n)) = A000035(n). [Maps odd numbers larger than one to primes, and even numbers to composites, in some order. Permutations A246380 & A246682 have the same property].
PROG
(PARI)
A002808(n) = { my(k=-1); while( -n + n += -k + k=primepi(n), ); n }; \\ This function from M. F. Hasler
A246378(n) = if(1==n, 1, if(!(n%2), A002808(A246378(n/2)), prime(A246378((n-1)/2))));
for(n=1, 4096, write("b246378.txt", n, " ", A246378(n)));
(Scheme, with memoizing definec-macro)
(definec (A246378 n) (cond ((< n 2) n) ((even? n) (A002808 (A246378 (/ n 2)))) (else (A000040 (A246378 (/ (- n 1) 2))))))
CROSSREFS
Inverse: A246377.
Similar or related permutations: A237126, A054429, A227413, A236854, A246375, A246380, A246682, A163511.
Sequence in context: A101690 A213781 A257730 * A260422 A237126 A246380
KEYWORD
nonn,look
AUTHOR
Antti Karttunen, Aug 27 2014
STATUS
approved