[Java] Count Entries by Greatest Common Divisor
\n    public long coutPairs(int[] nums, int k) {\n        HashMap<Integer, Integer> map = new HashMap<>();\n        long output = 0;\n        for (int num : num
```\n    public long coutPairs(int[] nums, int k) {\n        HashMap<Integer, Integer> map = new HashMap<>();\n        long output = 0;\n        for (int num : nums) {\n            int gcd = countPairs(k, num);\n            for (Map.Entry<Integer, Integer> entry : map.entrySet()) if (((long) gcd * entry.getKey()) % k == 0) output += entry.getValue();\n            map.put(gcd, map.getOrDefault(gcd, 0) + 1);\n        }\n        return output;\n    }\n    \n    private int countPairs(int i, int j) {\n        return i == 0 ? j : countPairs(j % i, i);\n    }\n```
['Java']