Prime triplets: Difference between revisions

m
→‎{{header|REXX}}: optimized and simplified some code.
(→‎{{header|REXX}}: added the computer programming language REXX.)
m (→‎{{header|REXX}}: optimized and simplified some code.)
Line 129:
Tprimes= 0; idx= 1 /*initialize # prime triplets & index.*/
$= /*a list of prime triplets (so far). */
do j=1 to lim; p2= @.j+2; p6= p2 + 4 /*look for prime triplets within range.*/
ifp2= \!@.p2j + |2; if \!.p6p2 then iterate /*Areis P2 &P2 P6 prime? No, then skip it. */
p6= p2 + 4; if \!.p6 then iterate /* " P6 " " " " " */
Tprimes= Tprimes + 1 /*bump the number of prime triplets. */
if cols==0 then iterate then iterate /*Build the list (to be shown later)? */
@@@= commas(@.j)__ commas(p2)__ commas(p6) /*add commas & blanks to prime triplet.*/
$= $ left( '('@@@")", w) /*add a prime triplet ──► the $ list.*/
if Tprimes//cols\==0 then iterate then iterate /*have we populated a line of output? */
say center(idx, 7)'│' strip(substr($, 2), 'T'); $= /*show what we have so far.*/
idx= idx + cols /*bump the index count for the output*/