Pythagorean triples: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: changed and add comments, changed some REXX variable names. |
m →using single evenness for determinacy: added and changed some comments, changed some REXX variable names. |
||
Line 3,218:
<lang rexx>/*REXX program counts the number of Pythagorean triples that exist given a maximum */
/*──────────────────── perimeter of N, and also counts how many of them are primitives.*/
parse arg N . /*obtain optional argument from the CL.*/
if N=='' | N=="," then n=100 /*Not specified? Then use the default.*/
T=0; P=0 /*set the number of Triples, Primitives*/
@.=0; do a=3 to N%3; aa=a*a
do b=a+1 by 1+aEven /*the triangle can't be isosceles. */
if aEven then if c//2==0 then iterate
am=a*m; bm=b*m; cm=c*m /*create some short-cut variable names.*/
end /*
_=left('', 7) /*for padding the output with 7 blanks.*/
say 'max perimeter =' N _ "Pythagorean triples ="
/*stick a fork in it, we're all done. */</lang>
'''output''' is identical to the 1<sup>st</sup> REXX version.
|