diff --git a/contents/euclidean_algorithm/code/python/euclidean_example.py b/contents/euclidean_algorithm/code/python/euclidean_example.py index 367aed512..0badc2ca8 100644 --- a/contents/euclidean_algorithm/code/python/euclidean_example.py +++ b/contents/euclidean_algorithm/code/python/euclidean_example.py @@ -13,6 +13,11 @@ def euclid_sub(a, b): a = abs(a) b = abs(b) + if a == 0: + return b + elif b == 0: + return a + while a != b: if a > b: a -= b diff --git a/contents/euclidean_algorithm/euclidean_algorithm.md b/contents/euclidean_algorithm/euclidean_algorithm.md index 0de143dac..035e7ae81 100644 --- a/contents/euclidean_algorithm/euclidean_algorithm.md +++ b/contents/euclidean_algorithm/euclidean_algorithm.md @@ -24,7 +24,7 @@ The algorithm is a simple way to find the *greatest common divisor* (GCD) of two {% sample lang="lisp" %} [import:3-12, lang="lisp"](code/clisp/euclidean.lisp) {% sample lang="py" %} -[import:11-22, lang="python"](code/python/euclidean_example.py) +[import:11-27, lang="python"](code/python/euclidean_example.py) {% sample lang="hs" %} [import:3-13, lang="haskell"](code/haskell/euclidean_algorithm.hs) {% sample lang="rs" %}