login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 2
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, 27, 28, 11, 30, 79, 32, 14, 57, 35, 36, 37, 69, 22, 40, 101, 42, 17, 44, 45, 87, 47, 48, 49, 50, 26, 52, 53, 54, 55, 56, 34, 93, 139, 60, 61, 111, 63 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
This is an involution on the natural numbers: applying it twice gives the identity permutation.
LINKS
A. B. Frizell, Certain non-enumerable sets of infinite permutations. Bull. Amer. Math. Soc. 21 (1915), no. 10, 495-499.
MAPLE
f:= proc(t)
local r;
if t mod 2 = 0 and isprime(t/2) then 3*nextprime(t/2)
elif t mod 3 = 0 and isprime(t/3) then 2*prevprime(t/3)
elif isprime(t) then
r:= numtheory:-pi(t);
if isprime(r) then ithprime(2*r)
elif r mod 2 = 0 and isprime(r/2) then ithprime(r/2)
else t
fi
else t
fi
end proc:
seq(f(i), i=1..100); # Robert Israel, Dec 26 2014
MATHEMATICA
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]];
Array[f, 100] (* Jean-François Alcover, Jul 27 2020, after Robert Israel *)
PROG
(Python)
from sympy import isprime, primepi, prevprime, nextprime, prime
def A253047(n):
....if n <= 2:
........return n
....if n == 3:
........return 7
....q2, r2 = divmod(n, 2)
....if r2:
........q3, r3 = divmod(n, 3)
........if r3:
............if isprime(n):
................m = primepi(n)
................if isprime(m):
....................return prime(2*m)
................x, y = divmod(m, 2)
................if not y:
....................if isprime(x):
........................return prime(x)
............return n
........if isprime(q3):
............return 2*prevprime(q3)
........return n
....if isprime(q2):
........return 3*nextprime(q2)
....return n # Chai Wah Wu, Dec 27 2014
CROSSREFS
Sequence in context: A165474 A056904 A319838 * A077470 A347370 A205559
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Dec 26 2014
EXTENSIONS
Definition supplied by Robert Israel, Dec 26 2014
Offset changed to 1 by Chai Wah Wu, Dec 27 2014
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 29 07:58 EDT 2024. Contains 372098 sequences. (Running on oeis4.)