Skip to content

Commit

Permalink
Fixed infinite loop issue in "euclidean_example.py" (algorithm-archiv…
Browse files Browse the repository at this point in the history
…ists#749)

* Fixed infinite loop issue in "euclidean_example.py"

* Changed line numbers in "euclidean_algorithm.md" for python
  • Loading branch information
valdaarhun authored Sep 11, 2020
1 parent aa08db0 commit a4dbc2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions contents/euclidean_algorithm/code/python/euclidean_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contents/euclidean_algorithm/euclidean_algorithm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}
Expand Down

0 comments on commit a4dbc2a

Please sign in to comment.