From 50092c84854fa0afa53e076ad8bd95df746cfefd Mon Sep 17 00:00:00 2001 From: chmod777 Date: Fri, 6 Jul 2018 22:15:25 +0100 Subject: [PATCH 1/2] Cleaned up the code a bit made it use a one print instead of two and deleted the function that was handling the two prints and made it print directly and used a -= b, b -= a instead of a = a - b, b= b - a --- .../code/python/euclidean_example.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/chapters/euclidean_algorithm/code/python/euclidean_example.py b/chapters/euclidean_algorithm/code/python/euclidean_example.py index 3e6d22851..8546723c5 100644 --- a/chapters/euclidean_algorithm/code/python/euclidean_example.py +++ b/chapters/euclidean_algorithm/code/python/euclidean_example.py @@ -15,14 +15,11 @@ def euclid_sub(a, b): while a != b: if a > b: - a = a - b + a -= b else: - b = b - a + b -= a return a -def main(): - print(euclid_mod(64 * 67, 64 * 81)) - print(euclid_sub(128 * 12, 128 * 77)) - -main() +if __name__=="__main__": + print('Eucledean Mod: {}\nEucledean sub: {}'.format(euclid_mod(64 * 67, 64 * 81), euclid_sub(128 * 12, 128 * 77))) From 27899265f07af19b0c782465aefc3e88104ebd5b Mon Sep 17 00:00:00 2001 From: chmod777 Date: Sat, 7 Jul 2018 12:50:23 +0100 Subject: [PATCH 2/2] fixed some issues --- chapters/euclidean_algorithm/code/python/euclidean_example.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chapters/euclidean_algorithm/code/python/euclidean_example.py b/chapters/euclidean_algorithm/code/python/euclidean_example.py index 8546723c5..367aed512 100644 --- a/chapters/euclidean_algorithm/code/python/euclidean_example.py +++ b/chapters/euclidean_algorithm/code/python/euclidean_example.py @@ -22,4 +22,5 @@ def euclid_sub(a, b): return a if __name__=="__main__": - print('Eucledean Mod: {}\nEucledean sub: {}'.format(euclid_mod(64 * 67, 64 * 81), euclid_sub(128 * 12, 128 * 77))) + print('Euclidean mod: ', euclid_mod(64 * 67, 64 * 81)) + print('Euclidean sub: ', euclid_sub(128 * 12, 128 * 77))