Sum and product puzzle: Difference between revisions

m
→‎version 5: elided a shortcut and used the actual high limit specified (100 instead of 98).
m (→‎version 5: changed some comments and whitespace, separated the generation of primes and put the code into a more idiomatic subroutine.)
m (→‎version 5: elided a shortcut and used the actual high limit specified (100 instead of 98).)
Line 1,726:
===version 5===
<lang rexx>/*REXX program solves the Sum and Product Puzzle (also known as the Impossible Puzzle).*/
parse arg H; if H=='' | H=="," then H=98 100 /*obtain optional HIGH number from CL*/
@.=0; call genPrimes H /*generate all primes ≤ H. */
do s=2 for H-1; if C1(s)==0 then iterate /*find and display the puzzle solution.*/