Skip to content

Commit 98a2fac

Browse files
aquacash5zsparal
authored andcommitted
Removed unnessesary temp variable (#168)
* Removed unnessesary temp variable * Updated markdown to match modifications to the python file
1 parent 77d37bc commit 98a2fac

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

chapters/euclidean_algorithm/code/python/euclidean_example.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ def euclid_mod(a, b):
22

33
a = abs(a)
44
b = abs(b)
5-
temp = 0
65

76
while b > 0:
8-
temp = b
9-
b = a % b
10-
a = temp
7+
a, b = b, a % b
118

129
return a
1310

chapters/euclidean_algorithm/euclidean.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The algorithm is a simple way to find the *greatest common divisor* (GCD) of two
1616
{% sample lang="js" %}
1717
[import:15-29, lang="javascript"](code/javascript/euclidean_example.js)
1818
{% sample lang="py" %}
19-
[import:14-25, lang="python"](code/python/euclidean_example.py)
19+
[import:11-22, lang="python"](code/python/euclidean_example.py)
2020
{% sample lang="haskell" %}
2121
[import:3-11, lang="haskell"](code/haskell/euclidean_example.hs)
2222
{% sample lang="rs" %}
@@ -49,7 +49,7 @@ Modern implementations, though, often use the modulus operator (%) like so
4949
{% sample lang="js" %}
5050
[import:1-13, lang="javascript"](code/javascript/euclidean_example.js)
5151
{% sample lang="py" %}
52-
[import:1-12, lang="python"](code/python/euclidean_example.py)
52+
[import:1-9, lang="python"](code/python/euclidean_example.py)
5353
{% sample lang="haskell" %}
5454
[import:13-24, lang="haskell"](code/haskell/euclidean_example.hs)
5555
{% sample lang="rs" %}

0 commit comments

Comments
 (0)