login
A318295
Prime numbers whose digits can be permuted in multiple ways to yield primes.
1
103, 107, 113, 131, 137, 149, 157, 163, 167, 173, 179, 197, 199, 307, 311, 317, 337, 359, 373, 379, 389, 397, 419, 491, 571, 593, 613, 617, 631, 701, 709, 719, 733, 739, 751, 761, 839, 907, 919, 937, 941, 953, 971, 983, 991, 1009, 1013, 1019, 1021, 1031, 1033
OFFSET
1,1
COMMENTS
From Robert Israel, Sep 06 2018: (Start)
"Multiple ways" here means more than one nontrivial permutation other than the identity permutation, i.e., there are at least 3 different primes formed by permuting digits of this prime.
Leading 0's are allowed in the permutations. (End)
LINKS
EXAMPLE
131 belongs to this sequence as there are two nontrivial permutations of its digits which yield other primes, namely 113 and 311.
137 also belongs to this sequence. Even though 371, 713 and 731 are composite, 173 and 317 are prime, satisfying the requirement.
139 does not belong in this sequence. Although 193 is prime, 319, 391, 913 and 931 are all composite.
MAPLE
filter:= proc(n) local L, Lp, t, i, m, x;
if not isprime(n) then return false fi;
L:= convert(n, base, 10);
m:= nops(L);
Lp:= combinat:-permute(L);
t:= 1;
for i from 1 to nops(Lp) do
if Lp[i]=L then next fi;
x:= add(Lp[i][j]*10^(j-1), j=1..m);
if isprime(x) then
t:= t+1;
if t = 3 then return true fi;
fi
od;
false
end proc:
select(filter, [seq(i, i=11..2000, 2)]); # Robert Israel, Sep 06 2018
MATHEMATICA
Select[Prime[Range[200]], Count[PrimeQ[Map[FromDigits, Permutations[IntegerDigits[#]]]], True] > 2 &] (* Alonso del Arte, Aug 24 2018 *)
Select[Prime[Range[200]], Count[FromDigits/@Rest[Permutations[IntegerDigits[#]]], _?PrimeQ]>1&] (* Harvey P. Dale, Sep 25 2024 *)
PROG
(Python)
from itertools import *
nmax=1000
def is_prime(num):
if num == 0 or num == 1: return(0)
for k in range(2, num):
if (num % k) == 0:
return(0)
return(1)
ris = ""
for i in range(nmax):
f=0
lf=[]
if is_prime(i):
for p in permutations(str(i), len(str(i))):
k=int(''.join(p))
if k!=i and is_prime(k):
if k not in lf:
f+=1
lf.append(k)
if f>1:
ris = ris+str(i)+", "
break
print(ris)
CROSSREFS
Subsequence of A055387.
Sequence in context: A167841 A213311 A161402 * A165294 A046076 A178527
KEYWORD
nonn,base
AUTHOR
Pierandrea Formusa, Aug 23 2018
EXTENSIONS
More terms from Giovanni Resta, Sep 03 2018
STATUS
approved