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
#= 0 /*number of Pierpont primes (so far). */
do t=1 to -1 by -2; usum= 0; vsum= 0; s= 0 /*T is 1, then -1.*/
w= 0 /*the max width of a Pierpont prime. */
#= 0 /*number of Pierpont primes (so far). */
$=; do j=0 until #>=n /*$: the list of the Pierpont primes. */
w= 0 /*maximum width of a Pierpont prime. */
if usum<=s then usum= get(2, 3); if vsum<=s then vsum= get(3, 2)
$=; do j=0 until #>=n /*$: the list of the Pierpont primes.*/
s= min(vsum, usum); if \isPrime(s) then iterate /*get min; is prime? */
if usum<=s then usum= get(2, 3); if vsum<=s then vsum= get(3, 2)
#= # + 1; $= $ s /*bump counter; append.*/
s= min(vsum, usum); if \isPrime(s) then iterate /*get min; is prime? */
w= max(w, length(s) ) /*find max prime width.*/
#= # + 1; $= $ s /*bump counter; append.*/
end /*j*/
w= max(w, length(s) ) /*find max prime width.*/
say
end /*j*/
say
if t==1 then @= '1st' /*choose word for type.*/
else @= '2nd' /* " " " " */
if t==-1 then @= '2nd' /*choose word for type.*/
say center(n " Pierpont primes of the " @ ' kind', max(10*(w+1) -1, 79), "═")
say center(n " Pierpont primes of the " @ ' kind', max(10*(w+1)-1, 79), "═")
call show $ /*display the primes. */
call show $ /*display the primes. */
end /*type*/
end /*t*/
exit /*stick a fork in it, we're all done. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/