BigInteger Modpow
时间: 2023-11-20 19:05:35 浏览: 97
BigInteger
BigInteger.modPow(BigInteger exponent, BigInteger m) is a method in the BigInteger class of Java that computes the modular exponentiation of a BigInteger value raised to the power of another BigInteger value modulo a third BigInteger value.
The method takes two BigInteger arguments: exponent and m. The exponent is the power to which the BigInteger value will be raised, while m is the modulus. The method returns a BigInteger value that is the result of the modular exponentiation.
Syntax:
```
public BigInteger modPow(BigInteger exponent, BigInteger m)
```
Example:
```
import java.math.BigInteger;
public class ModPowExample {
public static void main(String[] args) {
BigInteger base = new BigInteger("123456789");
BigInteger exponent = new BigInteger("987654321");
BigInteger modulus = new BigInteger("1000000007");
BigInteger result = base.modPow(exponent, modulus);
System.out.println(base + "^" + exponent + " mod " + modulus + " = " + result);
}
}
```
Output:
```
123456789^987654321 mod 1000000007 = 417934045
```
阅读全文