from sympy import isprimenextprime
from itertoolscollections import combinations_with_replacementCounter
from sympy.utilities.iterables import multiset_permutations
s = "".join(nzt) if "0" not in t else nz[0]+"0"*t.count("0")+nz[1:]
mxc, argmx = -p = Counter(), nextprime(10**(n-1, None))
for u in combinations_with_replacement("0123456789", n):
s, first, ufirst = 0, False, None
if sum(int(ui) for ui in u)%3 != 0:
while p < 10**n:
c["".join(sorted(str(p)))] += 1
p = nextprime(p)
m = min(c.most_common(1))
return smallest(m[0]) # m[1] generates A065851
print([a(n) for pn in multiset_permutationsrange(u):2, 7)]) # _Michael S. Branicky_, May 28 2024
if p[0] != "0" and isprime(int("".join(p))):
s += 1
if not first:
ufirst, first = int("".join(p)), True
if s > mx:
mx, argmx = s, u # use ufirst for smallest prime
return smallest(argmx) # mx here generates A065851
print([a(n) for n in range(1, 8)]) # Michael S. Branicky, May 27 2024
|