The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.



(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A318295 Prime numbers such that there are multiple permutations of their digits which are still prime. 1


%S 103,107,113,131,137,149,157,163,167,173,179,197,199,307,311,317,337,

%T 359,373,379,389,397,419,491,571,593,613,617,631,701,709,719,733,739,

%U 751,761,839,907,919,937,941,953,971,983,991,1009,1013,1019,1021,1031,1033

%N Prime numbers such that there are multiple permutations of their digits which are still prime.

%C From _Robert Israel_, Sep 06 2018: (Start)

%C "Multiple" 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.

%C Leading 0's are allowed in the permutations. (End)

%H Robert Israel, <a href="/A318295/b318295.txt">Table of n, a(n) for n = 1..10000</a>

%e 131 belongs to this sequence as there are more than one permutation of his digits which are still prime, namely 113 and 311.

%e 137 also belongs to this sequence. Even though 371, 713 and 731 are composite, 173 and 317 are prime, satisfying the requirement.

%e 139 does not belong in this sequence. Although 193 is prime, 319, 391, 913 and 931 are all composite.

%p filter:= proc(n) local L,Lp,t,i,m,x;

%p if not isprime(n) then return false fi;

%p L:= convert(n,base,10);

%p m:= nops(L);

%p Lp:= combinat:-permute(L);

%p t:= 1;

%p for i from 1 to nops(Lp) do

%p if Lp[i]=L then next fi;

%p x:= add(Lp[i][j]*10^(j-1),j=1..m);

%p if isprime(x) then

%p t:= t+1;

%p if t = 3 then return true fi;

%p fi

%p od;

%p false

%p end proc:

%p select(filter, [seq(i,i=11..2000,2)]); # _Robert Israel_, Sep 06 2018

%t Select[Prime[Range[200]], Count[PrimeQ[Map[FromDigits, Permutations[IntegerDigits[#]]]], True] > 2 &] (* _Alonso del Arte_, Aug 24 2018 *)

%o (Python)

%o from itertools import *

%o nmax=1000

%o def is_prime(num):

%o if num == 0 or num == 1: return(0)

%o for k in range(2, num):

%o if (num % k) == 0:

%o return(0)

%o return(1)

%o ris = ""

%o for i in range(nmax):

%o f=0

%o lf=[]

%o if is_prime(i):

%o for p in permutations(str(i), len(str(i))):

%o k=int(''.join(p))

%o if k!=i and is_prime(k):

%o if k not in lf:

%o f+=1

%o lf.append(k)

%o if f>1:

%o ris = ris+str(i)+","

%o break

%o print(ris)

%Y Subsequence of A055387.

%K nonn,base

%O 1,1

%A _Pierandrea Formusa_, Aug 23 2018

%E More terms from _Giovanni Resta_, Sep 03 2018

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 8 11:31 EDT 2020. Contains 336298 sequences. (Running on oeis4.)