[Python] Short || Math
\n# Code\n\nclass Solution:\n    def countPairs(self, nums: List[int], k: int) -> int:\n        def gcd(x, y):\n            while x % y != 0: x, y = y, x % y\n 
\n# Code\n```\nclass Solution:\n    def countPairs(self, nums: List[int], k: int) -> int:\n        def gcd(x, y):\n            while x % y != 0: x, y = y, x % y\n            return y\n        gcds, cnt, ans = [gcd(num, k) for num in nums], defaultdict(int), 0\n        for g in gcds: cnt[k // g] += 1\n        for g in gcds:\n            for f in cnt: ans += cnt[f] if not g % f else 0\n            ans -= not g % (k // g) \n        return ans // 2\n```
['Math', 'Number Theory', 'Python3']