You are viewing a single comment's thread. Return to all comments →
Below is my implementation in scala
Btw, I think the third would be the number of divisors of result_1/result_2
def gcd(a: Int, b: Int):Int=if (b==0) a.abs else gcd(b, a%b)
def lcm(a: Int, b: Int)=(a*b).abs/gcd(a,b)
val g = a.reduceLeft((x,y) => lcm(x,y))
val l = b.reduceLeft((x,y) => gcd(x,y))
val ans = (1 to l/g) count(x => l%(x*g) == 0 )
Hey, where are you learning scala? Thats the language I want to learn the most right now.
I took two courses from coursera, and I read a book called "Learning Scala".