diff --git a/chapters/euclidean_algorithm/code/python/euclidean_example.py b/chapters/euclidean_algorithm/code/python/euclidean_example.py index 3e81f47dc..3e6d22851 100644 --- a/chapters/euclidean_algorithm/code/python/euclidean_example.py +++ b/chapters/euclidean_algorithm/code/python/euclidean_example.py @@ -2,12 +2,9 @@ def euclid_mod(a, b): a = abs(a) b = abs(b) - temp = 0 while b > 0: - temp = b - b = a % b - a = temp + a, b = b, a % b return a diff --git a/chapters/euclidean_algorithm/euclidean.md b/chapters/euclidean_algorithm/euclidean.md index 1ccb40c9a..2e2db0fc5 100644 --- a/chapters/euclidean_algorithm/euclidean.md +++ b/chapters/euclidean_algorithm/euclidean.md @@ -16,7 +16,7 @@ The algorithm is a simple way to find the *greatest common divisor* (GCD) of two {% sample lang="js" %} [import:15-29, lang="javascript"](code/javascript/euclidean_example.js) {% sample lang="py" %} -[import:14-25, lang="python"](code/python/euclidean_example.py) +[import:11-22, lang="python"](code/python/euclidean_example.py) {% sample lang="haskell" %} [import:3-11, lang="haskell"](code/haskell/euclidean_example.hs) {% sample lang="rs" %} @@ -49,7 +49,7 @@ Modern implementations, though, often use the modulus operator (%) like so {% sample lang="js" %} [import:1-13, lang="javascript"](code/javascript/euclidean_example.js) {% sample lang="py" %} -[import:1-12, lang="python"](code/python/euclidean_example.py) +[import:1-9, lang="python"](code/python/euclidean_example.py) {% sample lang="haskell" %} [import:13-24, lang="haskell"](code/haskell/euclidean_example.hs) {% sample lang="rs" %}