2427. Number of Common Factors
On This Page
class Solution:
def commonFactors(self, a: int, b: int) -> int:
g = gcd(a, b)
res, x = 0, 1
while x * x <= g:
if g % x == 0:
res += 1
res += x * x < g
x += 1
return res