You are viewing a single comment's thread. Return to all comments →
Scala
object Solution { def gcd(x: Int, y: Int): Int = { if (y == 0) x else gcd(y, x % y) } def main(args: Array[String]): Unit = { val input = scala.io.StdIn.readLine().split(" ").map(_.toInt) val a = input(0) val b = input(1) val result = gcd(a, b) println(result) } }
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 →
Scala