Python Solution | Simple
Algorithm:\n First find factors of all the numbers from 1 to 10^5.\n Create a list store of size 10^5 and set all the values to zero.\n Initialize ans=0.\n Then
#### **Algorithm:**\n* First find factors of all the numbers from **1** to **10^5**.\n* Create a list **store** of size **10^5** and set all the values to zero.\n* Initialize **ans=0**.\n* Then for each number **i** in **nums**:\n    1. find the **gcd(i, k)**.\n   1. **min_fact = k/gcd**\n   1. **ans += store[min_fact]**\n   1. Now for each factor **j** of **i**,increment **store[j]** by **1**.\n* Finally return **ans**.\n\n### Code:\n```\nimport math\nn = 10**5+1\nfacts = [[] for i in range(n)]\nfor i in range(1,n):\n    for j in range(i,n,i):\n        facts[j].append(i)\n\nclass Solution:\n    def coutPairs(self, nums: List[int], k: int) -> int:\n        store = [0]*(10**5+1)\n        ans = 0\n        for i in nums:\n            GCD = math.gcd(i,k)\n            min_fact = k//GCD\n            ans += store[min_fact]\n            for j in facts[i]:\n                store[j]+=1\n        return ans\n```
[]