N-smooth numbers: Difference between revisions

Clearer again.
(Clearer again.)
Line 2,351:
=={{header|PARI/GP}}==
<syntaxhighlight lang="pari">
Vi_smooth( V0, C= 20)= {
upto(n, V0= primes(3) )= { /* default 3: [2,3,5] */
my( NW= #V0, rV_r= Vec([1],nC), v= V0, ix= vector(NW,i,1), t );
for(m c= 2, nC
, rV_r[mc]= t= vecmin(v);
for(i w= 1, NW
, if( v[iw] == t, v[iw]= V0[iw] * rV_r[ ix[iw]++] ]);
);
);r
V_r
}
N_smooth(N,C)= Vi_smooth(primes([0,N]),C)
S7(C)= N_smooth(7,C)[C]
 
S7Vi_smooth(n)= upto(n, primes(43))[n]; /* 7initial twenty 5-smooth-values */
 
upto(20) /* 5-smooth */
S7(1691)
S7(10^6)
my(p=509,ns=30000,c=20); uptoVi_smooth(n+c-1,primes([0,p]),s+c-1)[ns..ns+c-1]
</syntaxhighlight>
{{out}}
15

edits