|
|
A046893
|
|
a(n) is the least number with exactly n permutations of digits that are primes.
|
|
1
|
|
|
1, 2, 13, 103, 107, 1007, 1036, 1019, 1013, 1049, 1079, 1237, 10099, 10013, 10135, 10123, 10039, 10127, 10079, 10238, 10234, 10235, 10139, 10478, 12349, 12347, 10378, 12359, 14579, 10789, 100336, 10237, 12389, 23579, 10279, 100136, 12379, 10379, 100267, 13789
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,2
|
|
COMMENTS
|
Permutations that have leading zeros are included, in contrast to A046890 where they are not.
If neither A046890(n) nor a(n) have the digit 0, then they are equal. (End)
|
|
LINKS
|
|
|
MAPLE
|
g:= proc(d) local x, d1, y;
[seq(seq(seq(x*10^d + y, y = [0, h(x, d1)]), d1=0..d-1), x=1..9)]
end proc:
g(0):= [$0..9]:
h:= proc(x0, d) local y, z; option remember;
seq(seq(y*10^d+z, z = [procname(y, d-1)]), y=x0..9)
end proc:
for x0 from 1 to 9 do h(x0, 0):= $x0 .. 9 od:
f:= proc(n) local t, L, d, P, i;
t:= 0;
L:= convert(n, base, 10); d:= nops(L);
for P in combinat:-permute(L) do
if isprime(add(P[i]*10^(i-1), i=1..d)) then t:= t+1 fi
od;
t
end proc:
N:= 100: # for a(0)..a(N)
V:= Array(0..N): count:= 0:
for d from 0 while count < N+1 do
for i in g(d) while count < N+1 do
v:= f(i);
if v <= N then
if V[v] = 0 then V[v]:= i; count:= count+1; fi;
fi
od od:
|
|
MATHEMATICA
|
a = Table[0, {40}]; Do[b = Count[ PrimeQ[ FromDigits /@ Permutations[ IntegerDigits[n]]], True]; If[b < 40 && a[[b + 1]] == 0, a[[b + 1]] = n; Print[b, " ", n]], {n, 1, 110000}]
|
|
PROG
|
(Python)
from sympy import isprime
from sympy.utilities.iterables import multiset_permutations as mp
from itertools import count, islice, combinations_with_replacement as mc
def nd(d): yield from ("".join((f, )+m) for f in "123456789" for m in mc("0123456789", d-1))
def c(s): return sum(1 for p in mp(s) if p[0]!="0" and isprime(int("".join(p))))
def agen(): # generator of sequence terms
n, adict = 0, dict()
for digs in count(1):
for s in nd(digs):
v = c(s)
if v not in adict: adict[v] = int(s)
while n in adict: yield adict[n]; n += 1
|
|
CROSSREFS
|
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|