Java Solution || easy for loop || easy to understand
\nclass Solution {\n    public int countPairs(int[] arr, int k) {\n        int cnt = 0;\n\n        for (int i = 0; i < arr.length - 1; i++) {\n            for (
```\nclass Solution {\n    public int countPairs(int[] arr, int k) {\n        int cnt = 0;\n\n        for (int i = 0; i < arr.length - 1; i++) {\n            for (int j = i+1; j < arr.length; j++) {\n                if (arr[i] == arr[j]) {\n                    if ((i*j) % k == 0) cnt++;\n                }\n            }\n        }\n\n        return cnt;\n    }\n}\n```
['Java']