A316787 Semipermutable Primes: One-digit primes and primes with 2 or more digits such that all permutations of their digits are primes except for permutations that place either 5 or even numbers in the units digit.
2, 3, 5, 7, 11, 13, 17, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 107, 113, 131, 149, 181, 199, 223, 227, 229, 241, 251, 277, 281, 283, 311, 337, 373, 401, 419, 421, 443, 449, 457, 461, 463, 467, 491, 503, 509, 521, 547, 557, 563, 569, 577, 587, 601, 607
Offset: 1
Examples
127 is not in the sequence since 271 is prime but neither 217 nor 721 are; to be in the sequence all of these numbers would have to be prime, and they would form an orbit of size 4 (by Name, permutations of these numbers ending in 2 are not considered). 241 and 421 are in the sequence and form an orbit of size 2 since these primes can be obtained by permutations that forbid the units digit to be an even number. 569 and 659 are in the sequence since these primes can be obtained by permutations that forbid the units digit to be either 5 or an even number.
Links
- Robert Israel, Table of n, a(n) for n = 1..134
Programs
-
Maple
filter:= proc(n) local L,m,i,t; if not isprime(n) then return false fi; L:= convert(n,base,10); m:=nops(L); for i in select(t -> member(L[t],[1,3,7,9]), [$1..m]) do for t in combinat:-permute(subsop(i=NULL, L)) do if not isprime(L[i]+add(10^j*t[j],j=1..m-1)) then return false fi od od; true end proc: select(filter, [2,seq(i,i=3..2000,2)]); # Robert Israel, Aug 31 2018
-
Mathematica
Select[Prime@Range[120], AllTrue[FromDigits /@ Permutations[IntegerDigits@ #], PrimeQ[#] || MemberQ[{0, 2, 4, 5, 6, 8}, Mod[#, 10]] &] &] (* Giovanni Resta, Jul 14 2018 *)
Comments