private static int Phi2(int n, List<Integer> primes) {
        ArrayList<Integer> dividers = new ArrayList<Integer>();
        for (Integer prime : primes) {
            if (n < prime) {
                break;
            }
            if (n % prime == 0) {
                dividers.add(prime);
            }
        }

        BigInteger numerator = BigInteger.valueOf(n);
        BigInteger denominator = BigInteger.ONE;
        for (Integer dividor : dividers) {
            int currentNumerator = dividor - 1;

            numerator = numerator.multiply(BigInteger.valueOf(currentNumerator));
            denominator = denominator.multiply(BigInteger.valueOf(dividor));
        }

        if (numerator.compareTo(denominator) < 0) {
            throw new RuntimeException(numerator + " / " + denominator + ": Bad fraction");
        } else {
            return numerator.divide(denominator).intValue();
        }
    }