<gouthampradhan>math_LargestComponentSizebyCommonFactor_1.java
private List<Integer> primes(int N, int[] A) {
    boolean[] P = new boolean[N + 1];
    int[] pF = new int[N + 1];
    int sqRt = (int) Math.sqrt(N);
    for (int i = 2; i <= sqRt; i++) {
      if (!P[i]) {
        for (int j = 2; ; j++) {
          if (i * j > N) break;
          P[i * j] = true;
          if (pF[i * j] == 0) {
            pF[i * j] = i;
          }
        }
      }
    }
    Map<Integer, Integer> result = new HashMap<>();
    for (int a : A) {
      if (a == 1) continue;
      int n = pF[a];
      while (n != 0) {
        result.putIfAbsent(n, 0);
        result.put(n, result.get(n) + 1);
        a /= n;
        n = pF[a];
      }
      result.putIfAbsent(a, 0);
      result.put(a, result.get(a) + 1);
    }
    return result.keySet().stream().filter(x -> result.get(x) > 1).collect(Collectors.toList());
  }
private List < Integer > var_1 ( int var_2 , int [ ] var_3 ) {
  boolean [ ] var_6 = new boolean [ var_2 + 1 ] ;
  int [ ] var_7 = new int [ var_2 + 1 ] ;
  int var_10 = ( int ) Math . sqrt ( var_2 ) ;
  for ( int var_12 = 2 ;
  var_12 <= var_10 ;
  var_12 ++ ) {
    if ( ! var_6 [ var_12 ] ) {
      for ( int var_13 = 2 ;
      ;
      var_13 ++ ) {
        if ( var_12 * var_13 > var_2 ) break ;
        var_6 [ var_12 * var_13 ] = true ;
        if ( var_7 [ var_12 * var_13 ] == 0 ) {
          var_7 [ var_12 * var_13 ] = var_12 ;
        }
      }
    }
  }
  Map < Integer , Integer > var_17 = new HashMap < > ( ) ;
  for ( int var_18 : var_3 ) {
    if ( var_18 == 1 ) continue ;
    int var_19 = var_7 [ var_18 ] ;
    while ( var_19 != 0 ) {
      var_17 . putIfAbsent ( var_19 , 0 ) ;
      var_17 . put ( var_19 , var_17 . get ( var_19 ) + 1 ) ;
      var_18 /= var_19 ;
      var_19 = var_7 [ var_18 ] ;
    }
    var_17 . putIfAbsent ( var_18 , 0 ) ;
    var_17 . put ( var_18 , var_17 . get ( var_18 ) + 1 ) ;
  }
  return var_17 . keySet ( ) . stream ( ) . filter ( var_26 -> var_17 . get ( var_26 ) > 1 ) . collect ( Collectors . toList ( ) ) ;
}
