File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
contents/euclidean_algorithm/code/scala Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ object Euclid {
3
3
def euclid_sub (a : Int , b : Int ): Int =
4
4
(Math .abs(a), Math .abs(b)) match {
5
5
case (0 , _) | (_, 0 ) => 0
6
- case (x, y) if x < y => euclid (x, y - x)
7
- case (x, y) if x > y => euclid (x - y, y)
6
+ case (x, y) if x < y => euclid_sub (x, y - x)
7
+ case (x, y) if x > y => euclid_sub (x - y, y)
8
8
case _ => a
9
9
}
10
10
@@ -15,8 +15,10 @@ object Euclid {
15
15
}
16
16
17
17
def main (args : Array [String ]): Unit = {
18
- println(euclid_sub(151 * 899 , 151 * 182 ))
19
- println(euclid_mod(151 * 899 , 151 * 182 ))
18
+ println(" [#]\n Modulus-based euclidean algorithm result:" )
19
+ println(euclid_mod(64 * 67 , 64 * 81 ))
20
+ println(" [#]\n Subtraction-based euclidean algorithm result:" )
21
+ println(euclid_sub(128 * 12 , 128 * 77 ))
20
22
}
21
23
22
24
}
You can’t perform that action at this time.
0 commit comments