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 3 that is the product of exactly n distinct primes.
2

%I #10 Sep 12 2024 17:34:46

%S 3,33,30,330,3570,30030,3015870,30120090,300690390,30043474230,

%T 304075581810,30035662366710,304250263527210,30078810535603830,

%U 3001252188252588270,32589158477190044730,3003056284355533696290

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

%H Chai Wah Wu, <a href="/A106413/b106413.txt">Table of n, a(n) for n = 1..45</a>

%e a(1) = 3, a(6) = 30030 = 2*3*5*7*11*13.

%p f:= proc(n) uses priqueue; local pq, t, p, x, i,L,v,Lp;

%p initialize(pq);

%p L:= [seq(ithprime(i),i=1..n)];

%p v:= convert(L,`*`);

%p insert([-v, L], pq);

%p do

%p t:= extract(pq);

%p x:= -t[1];

%p if floor(x/10^ilog10(x)) = 3 then return x fi;

%p L:= t[2];

%p p:= nextprime(L[-1]);

%p for i from n to 1 by -1 do

%p if i < n and L[i] <> prevprime(L[i+1]) then break fi;

%p Lp:= [op(L[1..i-1]),op(L[i+1..n]),p];

%p insert([-convert(Lp,`*`),Lp], pq)

%p od od;

%p end proc:

%p map(f, [$1..30]); # _Robert Israel_, Sep 12 2024

%o (Python)

%o from itertools import count

%o from math import prod, isqrt

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

%o def A106413(n):

%o if n == 1: return 3

%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 = 3*10**l-1, 4*10**l-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_, Sep 12 2024

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

%K base,nonn

%O 1,1

%A _Ray Chandler_, May 02 2005