OFFSET
1,1
COMMENTS
If it exists, a(46) > 5*10^11. - Lars Blomberg, Mar 31 2018
EXAMPLE
119 is in the sequence because every permutation of its digits excluding 119 (i.e., 191 and 911) is a prime.
11 is not in the sequence, because when 11 is removed from the set, no numbers are left.
MAPLE
lis := [];
for n from 1 to 10000 do
nn := convert(n, base, 10);
pp := combinat[permute](nn);
if nops(pp) = 1 then
next
end if;
lOk := true;
for p in pp do
if p = nn then
next: #exclude n
end if;
if `not`(isprime(convert(p, base, 10, 10^nops(p))[])) then
lOk := false; break
end if
end do;
if lOk then
lis := [op(lis), n]
end if
end do:
lis := lis;
MATHEMATICA
rnapQ[n_]:=Module[{p=Rest[FromDigits/@Permutations[IntegerDigits[ n]]]}, If[ Length[p]==0, False, AllTrue[p, PrimeQ]]]; Select[Range[80000], rnapQ] (* The program uses the AllTrue function from Mathematica version 10 *) (* Harvey P. Dale, Jan 24 2019 *)
PROG
(PARI) isok(n) = {v = []; d = digits(n); for (k=0, (#d)!-1, p = numtoperm(#d, k); dp = vector(#d, j, d[p[j]]); np = subst(Pol(dp), x, 10); v = Set(concat(v, np)); ); v = setminus(v, Set(n)); if (#v == 0, return (0)); for (k=1, #v, if (!isprime(v[k]), return (0)); ); return (1); } \\ Michel Marcus, Apr 18 2016
(Python)
from sympy import isprime
from itertools import count, islice, permutations
def agen(): yield from (k for k in count(1) if len(set(s:=str(k)))!=1 and all((t:=int("".join(m)))==k or isprime(t) for m in permutations(s)))
print(list(islice(agen(), 45))) # Michael S. Branicky, Dec 29 2023
CROSSREFS
KEYWORD
nonn,base,more
AUTHOR
César Eliud Lozada, Apr 18 2016
STATUS
approved