From 380a33aab2f13d70eb824db290fab49c779361b5 Mon Sep 17 00:00:00 2001 From: c252 Date: Sat, 6 Oct 2018 11:58:26 -0400 Subject: [PATCH 1/2] fixed formatting problems --- .../code/nim/euclid_algorithm.nim | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/contents/euclidean_algorithm/code/nim/euclid_algorithm.nim b/contents/euclidean_algorithm/code/nim/euclid_algorithm.nim index eaf128289..48822e94c 100644 --- a/contents/euclidean_algorithm/code/nim/euclid_algorithm.nim +++ b/contents/euclidean_algorithm/code/nim/euclid_algorithm.nim @@ -1,27 +1,27 @@ proc euclid_mod(in1, in2: int): int = - var - a = abs(in1) - b = abs(in2) + var + a = abs(in1) + b = abs(in2) - while b != 0: - var temp: int = b - b = a mod b - a = temp; + while b != 0: + let temp: int = b + b = a mod b + a = temp; return a proc euclid_sub(in1, in2: int): int = - var - a = abs(in1) - b = abs(in2) + var + a = abs(in1) + b = abs(in2) - while a != b: - if a > b: - a -= b - else: - b -= a + while a != b: + if a > b: + a -= b + else: + b -= a return a -echo euclid_sub(32*5,32*3) -echo euclid_mod(64*2,64*7) +echo euclid_sub(32*5, 32*3) +echo euclid_mod(64*2, 64*7) From 5e6b1aaa53fdd64399a7c899b16e6f9541784c6e Mon Sep 17 00:00:00 2001 From: c252 Date: Sat, 6 Oct 2018 14:31:17 -0400 Subject: [PATCH 2/2] changed inputs for consistency --- contents/euclidean_algorithm/code/nim/euclid_algorithm.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contents/euclidean_algorithm/code/nim/euclid_algorithm.nim b/contents/euclidean_algorithm/code/nim/euclid_algorithm.nim index 48822e94c..e8da73d1a 100644 --- a/contents/euclidean_algorithm/code/nim/euclid_algorithm.nim +++ b/contents/euclidean_algorithm/code/nim/euclid_algorithm.nim @@ -23,5 +23,5 @@ proc euclid_sub(in1, in2: int): int = return a -echo euclid_sub(32*5, 32*3) -echo euclid_mod(64*2, 64*7) +echo euclid_sub(64 * 67, 64 * 81) +echo euclid_mod(128 * 12, 128 * 77) \ No newline at end of file