[go: up one dir, main page]

login
A106413
Smallest number beginning with 3 that is the product of exactly n distinct primes.
2
3, 33, 30, 330, 3570, 30030, 3015870, 30120090, 300690390, 30043474230, 304075581810, 30035662366710, 304250263527210, 30078810535603830, 3001252188252588270, 32589158477190044730, 3003056284355533696290
OFFSET
1,1
LINKS
EXAMPLE
a(1) = 3, a(6) = 30030 = 2*3*5*7*11*13.
MAPLE
f:= proc(n) uses priqueue; local pq, t, p, x, i, L, v, Lp;
initialize(pq);
L:= [seq(ithprime(i), i=1..n)];
v:= convert(L, `*`);
insert([-v, L], pq);
do
t:= extract(pq);
x:= -t[1];
if floor(x/10^ilog10(x)) = 3 then return x fi;
L:= t[2];
p:= nextprime(L[-1]);
for i from n to 1 by -1 do
if i < n and L[i] <> prevprime(L[i+1]) then break fi;
Lp:= [op(L[1..i-1]), op(L[i+1..n]), p];
insert([-convert(Lp, `*`), Lp], pq)
od od;
end proc:
map(f, [$1..30]); # Robert Israel, Sep 12 2024
PROG
(Python)
from itertools import count
from math import prod, isqrt
from sympy import primerange, integer_nthroot, primepi, primorial
def A106413(n):
if n == 1: return 3
def g(x, a, b, c, m): yield from (((d, ) for d in enumerate(primerange(b+1, isqrt(x//c)+1), a+1)) if m==2 else (((a2, b2), )+d for a2, b2 in enumerate(primerange(b+1, integer_nthroot(x//c, m)[0]+1), a+1) for d in g(x, a2, b2, c*b2, m-1)))
def f(x): return int(sum(primepi(x//prod(c[1] for c in a))-a[-1][0] for a in g(x, 0, 1, 1, n)))
for l in count(len(str(primorial(n)))-1):
kmin, kmax = 3*10**l-1, 4*10**l-1
mmin, mmax = f(kmin), f(kmax)
if mmax>mmin:
while kmax-kmin > 1:
kmid = kmax+kmin>>1
mmid = f(kmid)
if mmid > mmin:
kmax, mmax = kmid, mmid
else:
kmin, mmin = kmid, mmid
return kmax # Chai Wah Wu, Sep 12 2024
KEYWORD
base,nonn
AUTHOR
Ray Chandler, May 02 2005
STATUS
approved