Java solution without Prime Factor!
```\n    int[] parent;\n    int[] size;\n    int res=0;\n    public int largestComponentSize(int[] A) {\n        parent=new int[A.length];\n        size=new int
```\n    int[] parent;\n    int[] size;\n    int res=0;\n    public int largestComponentSize(int[] A) {\n        parent=new int[A.length];\n        size=new int[A.length];\n        Map<Integer, List<Integer>> map=new HashMap<>();\n        Map<Integer, Integer> pos=new HashMap<>();\n        for(int i=0;i<A.length;i++) {\n            parent[i]=-1;\n            size[i]=1;\n            pos.put(A[i], i);\n            for(int j=1;j<=Math.sqrt(A[i]);j++) {\n                if(A[i]%j==0) {\n                    if(!map.containsKey(j)) map.put(j, new ArrayList<Integer>());\n                    map.get(j).add(A[i]);\n                    if(!map.containsKey(A[i]/j)) map.put(A[i]/j, new ArrayList<Integer>());\n                    map.get(A[i]/j).add(A[i]);\n                }\n            }\n        }\n        map.remove(1);\n        for(int i : map.keySet()) {\n            List<Integer> cur=map.get(i);\n            for(int j=0;j<cur.size()-1;j++) union(pos.get(cur.get(j)), pos.get(cur.get(j+1)));\n        }\n        return res;\n    }\n    \n    public int find(int x) {\n        while(parent[x]!=-1) x=parent[x];\n        return x;\n    }\n    \n    public void union(int x, int y) {\n        int px=find(x), py=find(y);\n        if(px!=py) {\n            if(size[px]<size[py]) {\n                parent[px]=py;\n                size[py]+=size[px];\n                res=Math.max(res, size[py]);\n            }\n            else {\n                parent[py]=px;\n                size[px]+=size[py];\n                res=Math.max(res, size[px]);\n            }\n        }\n    }
[]