• + 0 comments

    For scala, need to import scala.io.StdIn.readLine inside main.

        def main(args: Array[String]) {
            import  scala.io.StdIn.readLine
             acceptInputAndComputeGCD(readLine().trim().split(" ").map(x=>x.toInt).toList)
        }
    

    This works:

        def gcd(x: Int, y: Int): Int =
            if (x == y) x
            else gcd(Math.max(x, y) - Math.min(x, y), Math.min(x, y))
    

    Wondering what optimizations could be added.