Java: Short and concise
```java\nclass Solution {\n    public int largestComponentSize(int[] A) {\n        Map parent = new HashMap<>();\n\n        for (int num : A)\n            for (
```java\nclass Solution {\n    public int largestComponentSize(int[] A) {\n        Map<Integer,Integer> parent = new HashMap<>();\n\n        for (int num : A)\n            for (int fact = 2; fact*fact<=num; fact++)\n                if (num % fact == 0){\n                    union(num,fact,parent);\n                    union(num,num/fact,parent);\n                }\n\n        int max = 1;\n        Map<Integer,Integer> freq = new HashMap<>();\n        for (Integer v : A) {\n            int f = find(v,parent);\n            if (freq.containsKey(f)) {\n                freq.put(f, freq.get(f)+1);\n                max=Math.max(max,freq.get(f));\n            }\n            else freq.put(f,1);\n        }\n        return max;\n    }\n    \n    public void union(int n, int m, Map<Integer,Integer> p) {\n        int findN = find(n,p);\n        int findM = find(m,p);\n        if (findN < findM) p.put(findM,findN);\n        else p.put(findN,findM);\n    }\n\n    public int find(Integer i, Map<Integer,Integer> parent) {\n        if (parent.get(i) == null) parent.put(i,i);\n        while (i != parent.get(i)) i = parent.get(i);\n        return i;\n    }\n    \n}
[]