// This is related to computing totients.
// To make the totient smaller relative to the number, we must add new prime factors.
for (int p = 2; ; p = nextPrime(p)) {
numer = numer.multiply(BigInteger.valueOf(p - 1));
denom = denom.multiply(BigInteger.valueOf(p));
if (numer.multiply(TARGET_DENOMINATOR).compareTo(denom.multiply(TARGET_NUMERATOR)) < 0) {
for (int i = 1; i <= p; i++) {
BigInteger n = numer.multiply(BigInteger.valueOf(i));
BigInteger d = denom.multiply(BigInteger.valueOf(i)).subtract(BigInteger.ONE);
if (n.multiply(TARGET_DENOMINATOR).compareTo(d.multiply(TARGET_NUMERATOR)) < 0)
return d.add(BigInteger.ONE).toString();