C++ Solution
```\nclass Solution {\npublic:\n    int find(int x,vector&p){\n        if(p[x]==-1) return x;\n        p[x]=find(p[x],p);\n        return p[x];\n    }\n    void
```\nclass Solution {\npublic:\n    int find(int x,vector<int>&p){\n        if(p[x]==-1) return x;\n        p[x]=find(p[x],p);\n        return p[x];\n    }\n    void Union(int x,int y,vector<int>&p){\n        x=find(x,p);\n        y=find(y,p);\n        if(x!=y) p[y]=x;\n    }\n    int largestComponentSize(vector<int>& nums) {\n        vector<int>p(100001,-1);\n        for(int i=0;i<nums.size();i++){\n            for(int j=2;j*j<=nums[i];j++){\n                if(nums[i]%j==0) {\n                    Union(nums[i],j,p);\n                    Union(nums[i],nums[i]/j,p);\n                }\n            }\n        }\n        unordered_map<int,int> mp;\n        int count=0;\n        for(int i=0;i<nums.size();i++)\n        {\n            int p1 = find(nums[i],p);\n            count = max(count,1+mp[p1]);\n            mp[p1]+=1;\n        }\n        return count;\n    }\n};
[]