%I #36 Feb 01 2014 23:33:58
%S 1,4,9,2,16,7,6,13,3,19,26,17,8,23,41,5,12,67,10,29,59,37,14,83,179,
%T 11,43,331,20,47,39,109,277,157,53,431,22,1063,31,191,15,2221,27,61,
%U 211,71,30,599,1787,919,241,3001,35,73,8527,127,1153,79,21,19577,44,89,283
%N a(1)=1, then a(c) = p and a(p) = c, where c = T_c(r,k) and p = T_p(r,k), and where T_p contains the primes arranged in rows by the prime index chain and T_c contains the composites arranged in rows by the order of compositeness. See Formula.
%C Exchanges primes with composites, primeth primes with composith composites, etc.
%C Exchange the k-th prime of order j with the k-th composite of order j and vice versa.
%C Self-inverse permutation of positive integers.
%C If n is the composite number A236536(r,k), then a(n) is the corresponding prime A236542(r,k) at the same position (r,k). Vice versa, if n is the prime A236542(r,k), then a(n) is the corresponding composite A236536(r,k) at the same position. - _Andrew Weimholt_, Jan 28 2014
%C The original name for this entry did not produce this sequence, but instead A236854, which differs from this permutation for the first time at n=8, where A236854(8)=23, while here a(8)=13. - _Antti Karttunen_, Feb 01 2014
%H R. J. Mathar, <a href="/A135044/b135044.txt">Table of n, a(n) for n = 1..197</a>
%H N. Fernandez, <a href="http://www.borve.org/primeness/FOP.html">An order of primeness, F(p)</a>.
%H N. Fernandez, <a href="/A006450/a006450.html">An order of primeness</a> [cached copy, included with permission of the author]
%H <a href="/index/Per#IntegerPermutation">Index to permutations of positive integers</a>
%F a(1)=1, a(A236536(r,k))=A236542(r,k), a(A236542(r,k))=A236536(r,k)
%e From _Andrew Weimholt_, Jan 29 2014: (Start)
%e More generally, takes the primes organized in an array according to the sieving process described in the Fernandez paper:
%e Row[1](n) = 2, 7, 13, 19, 23, ...
%e Row[2](n) = 3, 17, 41, 67, 83, ...
%e Row[3](n) = 5, 59, 179, ...
%e Row[4](n) = 11, 277, ...
%e Lets call this T_p (n, k)
%e Also take the composites organized in a similar manner, except we use "composite" numbered positions in our sieve:
%e Row[1](n) = 4, 6, 8, 10, 14, 20, 22, ...
%e Row[2](n) = 9, 12, 15, 18, 24, ...
%e Row[3](n) = 16, 21, 25, ...
%e Lets call this T_c (n, k)
%e If we now take the natural numbers and swap each number (except for 1) with the number which holds the same spot in the other array, then we get the sequence: 1, 4, 9, 2, 16, 7, 6, 13, with for example a(8) = 13 (13 holds the same position in the 'prime' table as 8 does in the 'composite' table). (End)
%p A135044 := proc(n)
%p if n = 1 then
%p 1;
%p elif isprime(n) then
%p idx := -1 ;
%p for r from 1 do
%p for c from 1 do
%p if A236542(r,c) = n then
%p idx := [r,c] ;
%p end if;
%p if A236542(r,c) >= n then
%p break;
%p end if;
%p end do:
%p if type(idx,list) then
%p break;
%p end if;
%p end do:
%p A236536(r,c) ;
%p else
%p idx := -1 ;
%p for r from 1 do
%p for c from 1 do
%p if A236536(r,c) = n then
%p idx := [r,c] ;
%p end if;
%p if A236536(r,c) >= n then
%p break;
%p end if;
%p end do:
%p if type(idx,list) then
%p break;
%p end if;
%p end do:
%p A236542(r,c) ;
%p end if;
%p end proc: # _R. J. Mathar_, Jan 28 2014
%t Composite[n_Integer] := Block[{k = n + PrimePi@n + 1}, While[k != n + PrimePi@k + 1, k++ ]; k]; Compositeness[n_] := Block[{c = 1, k = n}, While[ !(PrimeQ@k || k == 1), k = k - 1 - PrimePi@k; c++ ]; c]; Primeness[n_] := Block[{c = 1, k = n}, While[ PrimeQ@k, k = PrimePi@k; c++ ]; c];
%t ckj[k_, j_] := Select[ Table[Composite@n, {n, 10000}], Compositeness@# == j &][[k]]; pkj[k_, j_] := Select[ Table[Prime@n, {n, 3000}], Primeness@# == j &][[k]]; f[0]=0; f[1] = 1;
%t f[n_] := If[ PrimeQ@ n, pn = Primeness@n; ckj[ Position[ Select[ Table[ Prime@ i, {i, 150}], Primeness@ # == pn &], n][[1, 1]], pn], cn = Compositeness@n; pkj[ Position[ Select[ Table[ Composite@ i, {i, 500}], Compositeness@ # == cn &], n][[1, 1]], cn]]; Array[f, 64] (* _Robert G. Wilson v_ *)
%Y Cf. A000040, A007097, A049076, A049078 - A049081, A058322, A058324 - A058328, A093046, A002808, A006508, A059981, A078442, A236854.
%K nonn
%O 1,2
%A _Katarzyna Matylla_, Feb 11 2008
%E Edited, corrected and extended by _Robert G. Wilson v_, Feb 18 2008
%E Name corrected by _Andrew Weimholt_, Jan 29 2014
|