Pythagorean triples: Difference between revisions

Content added Content deleted
m (→‎version 2: removed dead code subroutine [GCD], this version doesn't need it, corrected some spelling errors. -- ~~~~)
m (→‎version 1: corrected a spelling error. -- ~~~~)
Line 1,677: Line 1,677:
===version 1===
===version 1===
A brute force approach.
A brute force approach.
<lang rexx>/*REXX pgm countse number of Pythagorean triples that exist given a max */
<lang rexx>/*REXX pgm counts number of Pythagorean triples that exist given a max */
/* perimeter of N, and also count how many of them are primatives. */
/* perimeter of N, and also counts how many of them are primatives.*/


parse arg N .; if N=='' then n=100 /*get "N". If none, then assume.*/
parse arg N .; if N=='' then n=100 /*get "N". If none, then assume.*/
Line 1,713: Line 1,713:
max perimeter = 1000 Pythagorean triples = 325 primatives = 70
max perimeter = 1000 Pythagorean triples = 325 primatives = 70
</pre>
</pre>

===version 2===
===version 2===
Also a brute force approach.
Also a brute force approach.