Pierpont primes: Difference between revisions

m
→‎{{header|REXX}}: added/changed whitespace and comments, simplified program.
m (More efficient implementation of n-smooth number generator)
m (→‎{{header|REXX}}: added/changed whitespace and comments, simplified program.)
Line 1,705:
numeric digits n /*ensure enough decimal digs (bit int).*/
big= copies(9, digits() ) /*BIG: used as a max number (a limit).*/
@= '1st'
do t=1 to -1 by -2; usum= 0; vsum= 0; s= 0
#= 0do t=1 to -1 by -2; usum= 0; vsum= 0; s= 0 /*T is 1, then /*number of Pierpont primes (so far)-1. */
w #= 0 /*thenumber maxof widthPierpont ofprimes a Pierpont(so primefar). */
$ w=; 0 do j=0 until #>=n /*$:maximum the listwidth of thea Pierpont primesprime. */
$=; do j=0 if usum<until #>=sn then usum= get(2, 3); if vsum<=s then vsum= get(3, 2) /*$: the list of the Pierpont primes.*/
if usum<=s then usum= minget(vsum2, usum3); if \isPrime(vsum<=s) then iterate vsum= /*get(3, min; is prime? */2)
# s= #min(vsum, + 1usum); if $= $ \isPrime(s) then iterate /*get min; is prime? /*bump counter; append.*/
w #= max(w,# length(s)+ )1; $= $ s /*find maxbump primecounter; widthappend.*/
end w= max(w, length(s) ) /*jfind max prime width.*/
say end /*j*/
say
if t==1 then @= '1st' /*choose word for type.*/
if t==-1 elsethen @= '2nd' /*choose word for " " " " type.*/
say center(n " Pierpont primes of the " @ ' kind', max(10*(w+1) -1, 79), "═")
call show $ /*display the primes. */
end /*typet*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/