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”).

Smallest number beginning with 8 that is the product of exactly n distinct primes.
2

%I #12 Sep 12 2024 19:35:13

%S 83,82,805,858,8610,81510,870870,80150070,800509710,8254436190,

%T 800680310430,8222980095330,800160280950030,80008785365579070,

%U 843685980760953330,80058789202898516010,8003887646839494820410

%N Smallest number beginning with 8 that is the product of exactly n distinct primes.

%H Chai Wah Wu, <a href="/A106418/b106418.txt">Table of n, a(n) for n = 1..43</a>

%e a(3) = 805 = 5*7*23.

%o (Python)

%o from itertools import count

%o from math import prod, isqrt

%o from sympy import primerange, integer_nthroot, primepi, primorial

%o def A106418(n):

%o if n == 1: return 83

%o 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)))

%o 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)))

%o def bisection(f,kmin,kmax,mmin,mmax):

%o while kmax-kmin > 1:

%o kmid = kmax+kmin>>1

%o mmid = f(kmid)

%o if mmid > mmin:

%o kmax, mmax = kmid, mmid

%o else:

%o kmin, mmin = kmid, mmid

%o return kmax

%o for l in count(len(str(primorial(n)))-1):

%o kmin, kmax = 8*10**l-1, 9*10**l-1

%o mmin, mmax = f(kmin), f(kmax)

%o if mmax>mmin: return bisection(f,kmin,kmax,mmin,mmax) # _Chai Wah Wu_, Aug 31 2024

%Y Cf. A077326-A077334, A106411-A106419, A106421-A106429.

%K base,nonn

%O 1,1

%A _Ray Chandler_, May 02 2005