login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A106415
Smallest number beginning with 5 that is the product of exactly n distinct primes.
2
5, 51, 506, 510, 5610, 51870, 510510, 50169210, 504894390, 50012172210, 503520607590, 50001975553530, 501601785815130, 50073188107872930, 5000089945706645790, 50617203592231346070, 5000858931483646541310
OFFSET
1,1
LINKS
EXAMPLE
a(4) = 510 = 2*3*5*17.
PROG
(Python)
from itertools import count
from math import prod, isqrt
from sympy import primerange, integer_nthroot, primepi, primorial
def A106415(n):
if n == 1: return 5
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 = 5*10**l-1, 6*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