connect only when the factor is >1
\nclass Solution {\npublic:\n    vector<int> p;\n    vector<int> r;\n    int gcd(int a , int b)\n    {\n          return b == 0 ? a : gcd(b, a % b);\n    }\n   
```\nclass Solution {\npublic:\n    vector<int> p;\n    vector<int> r;\n    int gcd(int a , int b)\n    {\n          return b == 0 ? a : gcd(b, a % b);\n    }\n    \n    int find(int k)\n    {\n        if(p[k] == k)\n            return k;\n        return p[k] = find(p[k]);\n    }\n    \n    void unon(int a, int b)\n    {\n        int pa = find(a);\n        int pb = find(b);\n        if(pa == pb)\n            return;\n        if(r[pa]>r[pb]){\n            p[pb] = pa;\n            r[pa]+=r[pb];\n        }\n        else{\n            p[pa] = pb;\n            r[pb]+=r[pa];\n        }\n    }\n    \n    int largestComponentSize(vector<int>& nums) {\n        int ii = 0;\n        p.resize(100002);\n        r.resize(100002);\n        for(int i=0;i<100002;i++)\n        {\n            p[i] = i;\n            r[i] = 1;\n        }\n        \n        \n        \n        int n = nums.size();\n        \n        for(int i=0;i<n;i++)\n            for(int j=2;j<=sqrt(nums[i]);j++)\n            {\n                if(nums[i]%j==0)\n                {\n                    unon(nums[i],j);\n                    unon(nums[i],nums[i]/j);\n                }\n            }\n        \n        \n        unordered_map<int, int> mp;\n        for(auto i: nums)\n        {\n            int y = find(i);\n            mp[y]++;\n        }\n        int res = 0;\n        for(auto i: mp)\n        {\n            res = max(res,i.second);\n        }\n        return res;\n    }\n};\n```
[]