OFFSET
0,2
COMMENTS
From Robert Israel, Feb 07 2023: (Start)
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
Robert Israel, Table of n, a(n) for n = 0..1477
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:
convert(V, list); # Robert Israel, Feb 07 2023
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
print(list(islice(agen(), 40))) # Michael S. Branicky, Feb 08 2023
CROSSREFS
KEYWORD
AUTHOR
STATUS
approved