%I #15 Aug 30 2024 02:54:03
%S 97,91,902,910,9030,91770,903210,9699690,900029130,9146807670,
%T 902340208770,9426343036110,900781858106130,90004386781078770,
%U 914836017997511610,90100977291211496610,9000008798605567472730,900002983747159323401370,9146570985683589524055990
%N Smallest number beginning with 9 that is the product of exactly n distinct primes.
%H Chai Wah Wu, <a href="/A106419/b106419.txt">Table of n, a(n) for n = 1..42</a>
%e a(2) = 91 = 7*13.
%o (PARI) a(n) = {i = prod(i=1, n, prime(i)); while ((digits(i)[1] != 9) || (omega(i) != n) || (bigomega(i) != n), i++); i;} \\ _Michel Marcus_, Sep 14 2013
%o (Python)
%o from itertools import count
%o from math import isqrt, prod
%o from sympy import primerange, integer_nthroot, primepi, primorial
%o def A106419(n):
%o if n == 1: return 97
%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 for l in count(len(str(primorial(n)))-1):
%o kmin, kmax = 9*10**l-1, 10**(l+1)-1
%o mmin, mmax = f(kmin), f(kmax)
%o if mmax>mmin:
%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 # _Chai Wah Wu_, Aug 29 2024
%Y Cf. A077326-A077334, A106411-A106419, A106421-A106429.
%K base,nonn
%O 1,1
%A _Ray Chandler_, May 02 2005
%E a(18)-a(19) from _Chai Wah Wu_, Aug 29 2024