A225035 Primes such that there is a nontrivial rearrangement of the digits which is a prime.
13, 17, 31, 37, 71, 73, 79, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 239, 241, 251, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 359, 367, 373, 379, 389, 397, 401, 419, 421
Offset: 1
Examples
13 is a term since a nontrivial permutation of its digits yields 31, which is also a prime.
References
- H.-E. Richert, On permutation prime numbers, Norsk. Mat. Tidsskr. 33 (1951), p. 50-53.
- Joe Roberts, Lure of the Integers, Math. Assoc. of Amer., 1992, p. 293.
- James J. Tattersall, Elementary Number Theory in Nine Chapters, Second Edition, Cambridge University Press, p. 121.
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
Programs
-
Maple
dmax:=3: # for all terms of up to dmax digits Res:= {}: p:= 1: do p:= nextprime(p); if p > 10^dmax then break fi; L:= sort(convert(p,base,10),`>`); m:= add(L[i]*10^(i-1),i=1..nops(L)); if assigned(A[m]) then if ilog10(A[m])=ilog10(p) then Res:= Res union {A[m], p} else Res:= Res union {p} fi else A[m]:= p fi od: sort(convert(Res,list)); # Robert Israel, Aug 13 2019
-
Mathematica
t={}; Do[p = Prime[n]; list1 = Permutations[IntegerDigits[p]]; If[Length[ Select[Table[FromDigits[n], {n,list1}], PrimeQ]] > 1, AppendTo[t,p]], {n,84}]; t
-
PARI
is(p) = if(isprime(p), my(d=vecsort(digits(p))); d==vector(#d,x,1)&&return(1); forperm(d, e, my(c = fromdigits(Vec(e))); p!=c && isprime(c) && return(1))); \\ Ruud H.G. van Tol, Jan 22 2023
-
Python
from sympy import isprime from itertools import permutations def ok(n): if not isprime(n): return False perms = (int("".join(p)) for p in permutations(str(n))) return any(isprime(t) for t in perms if t != n) print([k for k in range(500) if ok(k)]) # Michael S. Branicky, Sep 14 2022
Extensions
Edited by N. J. A. Sloane, Jan 22 2023
Comments