Swift Easy Clean Solution
\nclass Solution {\n    func countPairs(_ nums: [Int], _ k: Int) -> Int {\n        guard !nums.isEmpty else {return 0}\n        var numIndexDict : [Int : [Int]]
```\nclass Solution {\n    func countPairs(_ nums: [Int], _ k: Int) -> Int {\n        guard !nums.isEmpty else {return 0}\n        var numIndexDict : [Int : [Int]] = [:]\n        var count = 0\n        for (i,num) in nums.enumerated(){\n            var eArray = numIndexDict[num,default:[]]\n            eArray.forEach{ \n                count = ($0 * i % k == 0) ? count + 1 : count\n            }\n            eArray.append(i)\n            numIndexDict[num] = eArray\n        }\n        return count\n    }\n}\n```
['Swift']