cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

This page as a plain text file.
%I A251561 #22 May 22 2025 10:21:41
%S A251561 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 A251561 27,28,58,30,62,32,33,17,35,36,74,19,39,40,82,42,86,44,45,23,94,48,49,
%U A251561 50,51,52,106,54,55,56,57,29,118,60,122,31,63,64,65,66
%N A251561 A permutation of the natural numbers: interchange p and 2p for every prime p.
%C A251561 a(A001751(n)) != A001751(n). - _Reinhard Zumkeller_, Dec 27 2014
%H A251561 Michael De Vlieger, <a href="/A251561/b251561.txt">Table of n, a(n) for n = 1..10000</a>
%H A251561 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 A251561 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%t A251561 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 A251561 (Python)
%o A251561 from sympy import isprime
%o A251561 def A251561(n):
%o A251561     if n == 2:
%o A251561         return 4
%o A251561     q,r = divmod(n,2)
%o A251561     if r :
%o A251561         if isprime(n):
%o A251561             return 2*n
%o A251561         return n
%o A251561     if isprime(q):
%o A251561         return q
%o A251561     return n # _Chai Wah Wu_, Dec 26 2014
%o A251561 (Haskell)
%o A251561 a251561 1 = 1
%o A251561 a251561 n | q == 1                    = 2 * p
%o A251561           | p == 2 && a010051' q == 1 = q
%o A251561           | otherwise                 = n
%o A251561           where q = div n p; p = a020639 n
%o A251561 -- _Reinhard Zumkeller_, Dec 27 2014
%Y A251561 Cf. A064614, A253046.
%Y A251561  Cf. A020639, A010051, A001751.
%K A251561 nonn
%O A251561 1,2
%A A251561 _N. J. A. Sloane_, Dec 26 2014