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