2427. Number of Common Factors

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2427

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