Created
August 20, 2011 22:56
-
-
Save evansneath/1159789 to your computer and use it in GitHub Desktop.
Revisions
-
evansneath revised this gist
Aug 20, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,6 @@ def pythagorean_triples(n): while (b < n // 2): c = n - a - b if (a**2 + b**2 == c**2): return a, b, c b = b + 1 a, b = a + 1, 1 -
evansneath created this gist
Aug 20, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ def pythagorean_triples(n): """Finds a, b, and c such that a + b + c = n and a^2 + b^2 = c^2. Arguments: n: Value from which to determine pythagorean triples. Returns: Resulting combination of a, b, and c to satisfy the formula. """ a, b = 1, 1 while (a < n // 2): while (b < n // 2): c = n - a - b if (a**2 + b**2 == c**2): return(a, b, c) b = b + 1 a, b = a + 1, 1