[Java] Simple Solution
\nclass Solution {\n    public int find(int x,int []parent){\n        if(parent[x] == -1)return x;\n        parent[x] = find(parent[x],parent);\n        return 
```\nclass Solution {\n    public int find(int x,int []parent){\n        if(parent[x] == -1)return x;\n        parent[x] = find(parent[x],parent);\n        return parent[x];\n    }\n    \n    public void union(int x,int y,int[] parent){\n        int xp = find(x,parent);\n        int yp = find(y,parent);\n        if(xp != yp){\n            parent[yp] = xp;\n        }\n    }\n    \n    public int largestComponentSize(int[] nums) {\n        int n = nums.length;\n        int[] parent = new int[100001];\n        Arrays.fill(parent,-1);\n            \n        for(int i = 0;i<n;i++){\n            for(int k = 2;k<= Math.sqrt(nums[i]);k++){\n                if(nums[i] % k == 0){\n                    union(nums[i],k,parent);\n                    union(nums[i],nums[i]/k,parent);\n                }\n            }\n        }\n        \n        int count = 0;\n        Map<Integer,Integer> map = new HashMap<>();\n        for(int i= 0;i<n;i++){\n            int p = find(nums[i],parent);\n            count = Math.max(count,1 + map.getOrDefault(p,0));\n            map.put(p,1+map.getOrDefault(p,0));\n        }\n        \n        return count;\n    }\n}\n```
['Union Find', 'Java']