public HashSet<BigInteger> getFactors(BigInteger n) {
        HashSet<BigInteger> factors = new HashSet<BigInteger>();
        while (true) {
            for (BigInteger i : primes) {
                if (n.remainder(i).equals(ZERO)) {
                    n = n.divide(i);
                    factors.add(i);
                    break;
                }
            }
            if (n.equals(ONE)) return factors;
        }
    }