|
|
A272022
|
|
Look at the set of numbers obtained by permuting the digits of n in all possible ways, then remove n itself from the set. If the remaining numbers are all primes, then n is in the sequence.
|
|
0
|
|
|
13, 14, 16, 17, 20, 30, 31, 32, 34, 35, 37, 38, 50, 70, 71, 73, 74, 76, 79, 91, 92, 95, 97, 98, 110, 113, 118, 119, 131, 133, 199, 311, 337, 373, 733, 772, 775, 778, 779, 919, 991, 1118, 3337, 7771, 77779
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
|
|
LINKS
|
|
|
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)))
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,more
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|