You are viewing a single comment's thread. Return to all comments →
def gcd(x: Int, y: Int): Int = { if (x == y) { x } else { if (x % y == 0) { y } else gcd(y, x % y) } } def acceptInputAndComputeGCD(pair: List[Int]) = { val x = pair.head val y = pair.reverse.head var x_y = x > y println(gcd(if (x_y) x else y , if (x_y) y else x)) }
Seems like cookies are disabled on this browser, please enable them to open this website
Computing the GCD
You are viewing a single comment's thread. Return to all comments →