login
A permutation of the natural numbers: interchange p and 2p for every prime p.
3

%I #20 Dec 29 2014 08:13:29

%S 1,4,6,2,10,3,14,8,9,5,22,12,26,7,15,16,34,18,38,20,21,11,46,24,25,13,

%T 27,28,58,30,62,32,33,17,35,36,74,19,39,40,82,42,86,44,45,23,94,48,49,

%U 50,51,52,106,54,55,56,57,29,118,60,122,31,63,64,65,66

%N A permutation of the natural numbers: interchange p and 2p for every prime p.

%C a(A001751(n)) != A001751(n). - _Reinhard Zumkeller_, Dec 27 2014

%H Michael De Vlieger, <a href="/A251561/b251561.txt">Table of n, a(n) for n = 1..10000</a>

%H A. B. Frizell, <a href="http://dx.doi.org/10.1090/S0002-9904-1915-02686-8">Certain non-enumerable sets of infinite permutations</a>. Bull. Amer. Math. Soc. 21 (1915), no. 10, 495-499.

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%t a251561[n_] := Block[{f}, f[x_] := Which[PrimeQ[x], 2 x, PrimeQ[x/2], x/2, True, x]; Array[f, n]]; a251561[66] (* _Michael De Vlieger_, Dec 26 2014 *)

%o (Python)

%o from sympy import isprime

%o def A251561(n):

%o ....if n == 2:

%o ........return 4

%o ....q,r = divmod(n,2)

%o ....if r :

%o ........if isprime(n):

%o ............return 2*n

%o ........return n

%o ....if isprime(q):

%o ........return q

%o ....return n # _Chai Wah Wu_, Dec 26 2014

%o (Haskell)

%o a251561 1 = 1

%o a251561 n | q == 1 = 2 * p

%o | p == 2 && a010051' q == 1 = q

%o | otherwise = n

%o where q = div n p; p = a020639 n

%o -- _Reinhard Zumkeller_, Dec 27 2014

%Y Cf. A064614, A253046.

%Y Cf. A020639, A010051, A001751.

%K nonn

%O 1,2

%A _N. J. A. Sloane_, Dec 26 2014