login
A106425
Smallest number beginning with 5 and having exactly n prime divisors counted with multiplicity.
2
5, 51, 50, 54, 500, 504, 5000, 576, 512, 5184, 5120, 50176, 51200, 55296, 507904, 516096, 5038848, 589824, 524288, 5308416, 5242880, 51380224, 52428800, 56623104, 50331648, 509607936, 503316480, 5096079360, 536870912, 5435817984
OFFSET
1,1
EXAMPLE
a(4) = 54 = 2*3^3.
PROG
(Python)
from itertools import count
from math import isqrt, prod
from sympy import primerange, integer_nthroot, primepi
def A106425(n):
if n == 1: return 5
def g(x, a, b, c, m): yield from (((d, ) for d in enumerate(primerange(b, isqrt(x//c)+1), a)) if m==2 else (((a2, b2), )+d for a2, b2 in enumerate(primerange(b, integer_nthroot(x//c, m)[0]+1), a) 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(1<<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