login
Products of 9 distinct primes.
10

%I #51 Aug 31 2024 18:04:37

%S 223092870,281291010,300690390,340510170,358888530,363993630,

%T 380570190,397687290,406816410,417086670,434444010,455885430,

%U 458948490,481410930,485555070,497668710,504894390,512942430,514083570,531990690,538047510,547777230,551861310

%N Products of 9 distinct primes.

%H David A. Corneth, <a href="/A115343/b115343.txt">Table of n, a(n) for n = 1..10000</a> (first 1045 terms from Vincenzo Librandi and Chai Wah Wu)

%e 514083570 is in the sequence as it is equal to 2*3*5*7*11*13*17*19*53.

%p N:= 10^9: # to get all terms < N

%p n0:= mul(ithprime(i),i=1..8):

%p Primes:= select(isprime,[$1..floor(N/n0)]):

%p nPrimes:= nops(Primes):

%p for i from 1 to 9 do

%p for j from 1 to nPrimes do

%p M[i,j]:= convert(Primes[1..min(j,i)],`*`);

%p od od:

%p A:= {}:

%p for i9 from 9 to nPrimes do

%p m9:= Primes[i9];

%p for i8 in select(t -> M[7,t-1]*Primes[t]*m9 <= N, [$8..i9-1]) do

%p m8:= m9*Primes[i8];

%p for i7 in select(t -> M[6,t-1]*Primes[t]*m8 <= N, [$7..i8-1]) do

%p m7:= m8*Primes[i7];

%p for i6 in select(t -> M[5,t-1]*Primes[t]*m7 <= N, [$6..i7-1]) do

%p m6:= m7*Primes[i6];

%p for i5 in select(t -> M[4,t-1]*Primes[t]*m6 <= N, [$5..i6-1]) do

%p m5:= m6*Primes[i5];

%p for i4 in select(t -> M[3,t-1]*Primes[t]*m5 <= N, [$4..i5-1]) do

%p m4:= m5*Primes[i4];

%p for i3 in select(t -> M[2,t-1]*Primes[t]*m4 <= N, [$3..i4-1]) do

%p m3:= m4*Primes[i3];

%p for i2 in select(t -> M[1,t-1]*Primes[t]*m3 <= N, [$2..i3-1]) do

%p m2:= m3*Primes[i2];

%p for i1 in select(t -> Primes[t]*m2 <= N, [$1..i2-1]) do

%p A:= A union {m2*Primes[i1]};

%p od od od od od od od od od:

%p A; # _Robert Israel_, Sep 02 2014

%t Module[{n=6*10^8,k},k=PrimePi[n/Times@@Prime[Range[8]]];Select[ Union[ Times@@@ Subsets[Prime[Range[k]],{9}]],#<=n&]](* _Harvey P. Dale_ with suggestions from _Jean-François Alcover_, Sep 03 2014 *)

%t n = 10^9; n0 = Times @@ Prime[Range[8]]; primes = Select[Range[Floor[n/n0]], PrimeQ]; nPrimes = Length[primes]; Do[M[i, j] = Times @@ primes[[1 ;; Min[j, i]]], {i, 1, 9}, {j, 1, nPrimes}]; A = {};

%t Do[m9 = primes[[i9]];

%t Do[m8 = m9*primes[[i8]];

%t Do[m7 = m8*primes[[i7]];

%t Do[m6 = m7*primes[[i6]];

%t Do[m5 = m6*primes[[i5]];

%t Do[m4 = m5*primes[[i4]];

%t Do[m3 = m4*primes[[i3]];

%t Do[m2 = m3*primes[[i2]];

%t Do[A = A ~Union~ {m2*primes[[i1]]},

%t {i1, Select[Range[1, i2-1], primes[[#]]*m2 <= n &]}],

%t {i2, Select[Range[2, i3-1], M[1, #-1]*primes[[#]]*m3 <= n &]}],

%t {i3, Select[Range[3, i4-1], M[2, #-1]*primes[[#]]*m4 <= n &]}],

%t {i4, Select[Range[4, i5-1], M[3, #-1]*primes[[#]]*m5 <= n &]}],

%t {i5, Select[Range[5, i6-1], M[4, #-1]*primes[[#]]*m6 <= n &]}],

%t {i6, Select[Range[6, i7-1], M[5, #-1]*primes[[#]]*m7 <= n &]}],

%t {i7, Select[Range[7, i8-1], M[6, #-1]*primes[[#]]*m8 <= n &]}],

%t {i8, Select[Range[8, i9-1], M[7, #-1]*primes[[#]]*m9 <= n &]}],

%t {i9, 9, nPrimes}];

%t A (* _Jean-François Alcover_, Sep 03 2014, translated and adapted from Robert Israel's Maple program *)

%o (Python)

%o from operator import mul

%o from functools import reduce

%o from sympy import nextprime, sieve

%o from itertools import combinations

%o n = 190

%o m = 9699690*nextprime(n-1)

%o A115343 = []

%o for x in combinations(sieve.primerange(1,n),9):

%o y = reduce(mul,(d for d in x))

%o if y < m:

%o A115343.append(y)

%o A115343 = sorted(A115343) # _Chai Wah Wu_, Sep 02 2014

%o (Python)

%o from math import prod, isqrt

%o from sympy import primerange, integer_nthroot, primepi

%o def A115343(n):

%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(n+x-sum(primepi(x//prod(c[1] for c in a))-a[-1][0] for a in g(x,0,1,1,9)))

%o def bisection(f,kmin=0,kmax=1):

%o while f(kmax) > kmax: kmax <<= 1

%o while kmax-kmin > 1:

%o kmid = kmax+kmin>>1

%o if f(kmid) <= kmid:

%o kmax = kmid

%o else:

%o kmin = kmid

%o return kmax

%o return bisection(f) # _Chai Wah Wu_, Aug 31 2024

%o (PARI) is(n)=omega(n)==9 && bigomega(n)==9 \\ _Hugo Pfoertner_, Dec 18 2018

%Y Cf. A000040, A006881, A007304, A046386, A046387, A067885, A123321, A123322, A115343, A281222.

%K nonn,easy

%O 1,1

%A _Jonathan Vos Post_, Mar 06 2006

%E Corrected and extended by _Don Reble_, Mar 09 2006

%E More terms and corrected b-file from _Chai Wah Wu_, Sep 02 2014