Special pythagorean triplet: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: added wording to the REXX section header. |
→{{header|REXX}}: optimized execution of the three DO loops, used a better variable name for SUM, used better English when showing the number of solutions. |
||
Line 788:
<br>the next integer was used (for the previous DO loop).
<lang rexx>/*REXX pgm computes integers A, B, C that solve: 0<A<B<C; A+B+C = 1000; A^2+B^2 = C^2 */
parse arg
if
if hi=='' | hi=="," then hi= 1000
if n=='' | n=="," then n= 1
#= 0; pad= left('', 9) /*#: the number of solutions found. */
abc= ab
end
end
▲ end /*a*/
▲done: say pad pad pad # ' solutions found.'
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
s: if arg(1)==1 then return arg(3); return word(arg(2) 's', 1) /*simple pluralizer*/
show: #= #+1; say pad 'a=' a pad "b=" b pad 'c=' c; if #>=n then signal done; return</lang>
{{out|output|text= when using the default inputs:}}
|