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

A026239
Beginning with the natural numbers, swap the k-th prime and k-th composite.
8
1, 4, 6, 2, 8, 3, 9, 5, 7, 11, 10, 13, 12, 17, 19, 23, 14, 29, 15, 31, 37, 41, 16, 43, 47, 53, 59, 61, 18, 67, 20, 71, 73, 79, 83, 89, 21, 97, 101, 103, 22, 107, 24, 109, 113, 127, 25, 131, 137, 139, 149, 151, 26, 157, 163, 167, 173, 179, 27, 181, 28, 191, 193, 197, 199
OFFSET
1,2
COMMENTS
Involution (self-inverse permutation) of [positive] natural numbers.
FORMULA
a(1) = 1 and a(n) = if n is prime then A002808(A049084(n)) else A000040(A066246(n)) for n>1. - Reinhard Zumkeller, Dec 13 2001
MATHEMATICA
Composite[n_Integer] := FixedPoint[n + PrimePi@# + 1 &, n + PrimePi@n + 1]; f[1] = 1; f[n_] := If[ PrimeQ@n, Composite@ PrimePi@n, Prime[n - 1 - PrimePi@n]]; Array[f, 65] (* Robert G. Wilson v, Jun 08 2010 *)
PROG
(Haskell)
a026239 1 = 1
a026239 n | a010051 n == 1 = a002808 $ a049084 n
| otherwise = a000040 $ a066246 n
-- Reinhard Zumkeller, Mar 30 2014
CROSSREFS
Cf. A236854.
Sequence in context: A088516 A114538 A181096 * A171547 A114579 A021220
KEYWORD
nonn
EXTENSIONS
More terms from Robert G. Wilson v, Jun 08 2010
STATUS
approved