Anonymous user
Pythagorean triples: Difference between revisions
m
→{{header|REXX}}: changed some comments and indentations, added some comments.
m (→version 2: optimized a bit, added/changed some comments and indentation.) |
m (→{{header|REXX}}: changed some comments and indentations, added some comments.) |
||
Line 2,467:
<lang rexx>/*REXX pgm counts number of Pythagorean triples that exist given a max */
/* perimeter of N, and also counts how many of them are primitives.*/
trips=0; prims=0 /*zero # of triples, primatives. */
parse arg N .; if N=='' then n=100 /*get "N". If none, then assume.*/
do a=3 to N%3; aa=a*a /*limit side to 1/3 of perimeter.*/
cc=c*c
if
prims=prims+(gcd(a,b)==1)
end /*c*/
say 'max perimeter =' N, /*show a single line of output. */
left('',7) "Pythagorean triples =" trips, /*left('',
left('',7) 'primitives =' prims
exit /*stick a fork in it, we're done.*/
|