We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7bc0e22 commit 5a6ebd0Copy full SHA for 5a6ebd0
contents/euclidean_algorithm/code/nim/euclid_algorithm.nim
@@ -1,16 +1,16 @@
1
-proc euclid_mod(in1, in2: int): int =
+func euclid_mod(in1, in2: int): int =
2
var
3
a = abs(in1)
4
b = abs(in2)
5
-
+
6
while b != 0:
7
let temp: int = b
8
b = a mod b
9
a = temp;
10
11
- return a
+ result = a
12
13
-proc euclid_sub(in1, in2: int): int =
+func euclid_sub(in1, in2: int): int =
14
15
16
@@ -20,8 +20,9 @@ proc euclid_sub(in1, in2: int): int =
20
a -= b
21
else:
22
b -= a
23
24
25
26
-echo euclid_sub(64 * 67, 64 * 81)
27
-echo euclid_mod(128 * 12, 128 * 77)
+when isMainModule:
+ echo euclid_sub(64 * 67, 64 * 81)
28
+ echo euclid_mod(128 * 12, 128 * 77)
0 commit comments