You are viewing a single comment's thread. Return to all 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.
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 →
For scala, need to import scala.io.StdIn.readLine inside main.
This works:
Wondering what optimizations could be added.