OFFSET
0,2
COMMENTS
a(n) is the least k such that A131371(k) = n.
Leading zeros are not allowed.
LINKS
Robert Israel, Table of n, a(n) for n = 0..1000
EXAMPLE
a(3) = 123 because 123 has 3 anagrams that are semiprimes, namely 123 = 3 * 41, 213 = 3 * 71, and 321 = 3 * 107, and no smaller number works.
MAPLE
g:= proc(s, m) local t;
if s[1..m-1] = [0$(m-1)] then op(map(t -> [t, op(s)], [0, $(max(s) ..9)]))
else op(map(t -> [t, op(s)], [$(max(s) .. 9)]))
fi
end proc:
f:= proc(L, m) local P, t, i;
P:= select(t -> t[-1] <> 0 and numtheory:-bigomega(add(t[i]*10^(i-1), i=1..m))=2, combinat:-permute(L));
nops(P)
end proc:
V:= Array(0..100):
count:= 2: V[0]:= 1: V[1]:= 4:
L:= [seq(seq([b, a], b=[0, $a..9]), a=1..9)]:
for m from 2 while count < 101 do
for s in L while count < 101 do
v:= f(s, m);
if v <= 100 and V[v] = 0 then
V[v]:= add(s[i]*10^(i-1), i=1..m); count:= count+1;
fi
od;
L:= map(g, L, m)
od:
convert(V, list);
PROG
(Python)
from sympy import factorint
from sympy.utilities.iterables import multiset_permutations as mp
from itertools import count, islice, combinations_with_replacement as mc
def ndgen():
yield from ((f, )+r for d in count(1) for f in "123456789" for r in mc("0123456789", d-1))
def c(n): # is_semiprime
return sum(factorint(n).values()) == 2
def f(digs):
return sum(1 for p in mp(digs) if p[0]!="0" and c(t:=int("".join(p))))
def agen(): # generator of terms
adict, n = dict(), 0
for t in ndgen():
v = f(t)
if v not in adict: adict[v] = int("".join(t))
while n in adict: yield adict[n]; n += 1
print(list(islice(agen(), 46))) # Michael S. Branicky, Jun 12 2023
CROSSREFS
KEYWORD
AUTHOR
Robert Israel, Jun 11 2023
STATUS
approved