return modInverse(m);
return modInverse(m).modPow(exponent.negate(), m);
  public BigInteger modPow(BigInteger exponent, BigInteger m)  {    if (m.isNegative() || m.isZero())      throw new ArithmeticException("non-positive modulo");    if (exponent.isNegative())      return modInverse(m);    if (exponent.isOne())      return mod(m);    // To do this naively by first raising this to the power of exponent    // and then performing modulo m would be extremely expensive, especially    // for very large numbers.  The solution is found in Number Theory    // where a combination of partial powers and moduli can be done easily.    //    // We'll use the algorithm for Additive Chaining which can be found on    // p. 244 of "Applied Cryptography, Second Edition" by Bruce Schneier.    BigInteger s = ONE;    BigInteger t = this;    BigInteger u = exponent;    while (!u.isZero())      {	if (u.and(ONE).isOne())	  s = times(s, t).mod(m);	u = u.shiftRight(1);	t = times(t, t).mod(m);      }    return s;  }