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.
%I A253047 #29 May 22 2025 10:21:41 %S A253047 1,2,7,9,13,15,3,8,4,21,29,12,5,33,6,16,43,18,19,20,10,39,23,24,25,51, %T A253047 27,28,11,30,79,32,14,57,35,36,37,69,22,40,101,42,17,44,45,87,47,48, %U A253047 49,50,26,52,53,54,55,56,34,93,139,60,61,111,63 %N A253047 Start with the natural numbers 1,2,3,...; interchange 2*prime(i) and 3*prime(i+1) for each i, and interchange prime(prime(i)) with prime(2*prime(i)) for each i. %C A253047 This is an involution on the natural numbers: applying it twice gives the identity permutation. %H A253047 Chai Wah Wu, <a href="/A253047/b253047.txt">Table of n, a(n) for n = 1..10000</a> %H A253047 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 A253047 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %p A253047 f:= proc(t) %p A253047 local r; %p A253047 if t mod 2 = 0 and isprime(t/2) then 3*nextprime(t/2) %p A253047 elif t mod 3 = 0 and isprime(t/3) then 2*prevprime(t/3) %p A253047 elif isprime(t) then %p A253047 r:= numtheory:-pi(t); %p A253047 if isprime(r) then ithprime(2*r) %p A253047 elif r mod 2 = 0 and isprime(r/2) then ithprime(r/2) %p A253047 else t %p A253047 fi %p A253047 else t %p A253047 fi %p A253047 end proc: %p A253047 seq(f(i),i=1..100); # _Robert Israel_, Dec 26 2014 %t A253047 f[t_] := Module[{r}, Which[EvenQ[t] && PrimeQ[t/2], 3 NextPrime[t/2], Divisible[t, 3] && PrimeQ[t/3], 2 NextPrime[t/3, -1], PrimeQ[t], r = PrimePi[t]; Which[PrimeQ[r], Prime[2r], EvenQ[r] && PrimeQ[r/2], Prime[r/2], True, t], True, t]]; %t A253047 Array[f, 100] (* _Jean-François Alcover_, Jul 27 2020, after _Robert Israel_ *) %o A253047 (Python) %o A253047 from sympy import isprime, primepi, prevprime, nextprime, prime %o A253047 def A253047(n): %o A253047 if n <= 2: %o A253047 return n %o A253047 if n == 3: %o A253047 return 7 %o A253047 q2, r2 = divmod(n,2) %o A253047 if r2: %o A253047 q3, r3 = divmod(n,3) %o A253047 if r3: %o A253047 if isprime(n): %o A253047 m = primepi(n) %o A253047 if isprime(m): %o A253047 return prime(2*m) %o A253047 x, y = divmod(m,2) %o A253047 if not y: %o A253047 if isprime(x): %o A253047 return prime(x) %o A253047 return n %o A253047 if isprime(q3): %o A253047 return 2*prevprime(q3) %o A253047 return n %o A253047 if isprime(q2): %o A253047 return 3*nextprime(q2) %o A253047 return n # _Chai Wah Wu_, Dec 27 2014 %Y A253047 Cf. A064614, A253046, A253046. %K A253047 nonn %O A253047 1,2 %A A253047 _N. J. A. Sloane_, Dec 26 2014 %E A253047 Definition supplied by _Robert Israel_, Dec 26 2014 %E A253047 Offset changed to 1 by _Chai Wah Wu_, Dec 27 2014