• + 0 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)
        }
    }