You are viewing a single comment's thread. Return to all comments →
Python 3 ::
import math from functools import reduce def gcd_of_list(list): x = reduce(math.gcd, list) return x def lcm(denominators): return reduce(lambda a, b: a * b // math.gcd(a, b), denominators) l = lcm(a) g = gcd_of_list(b) i = lcm(a) ans = 0 while i <= g: if g%i == 0: ans += 1 i += l return ans
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 →
Python 3 ::