You are viewing a single comment's thread. Return to all comments →
Thanks 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 ) println(ans.toInt)
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
Thanks Below is my implementation in scala Btw, I think the third would be the number of divisors of result_1/result_2