Get a BigInteger whose value is (this ^ exponent mod m) in Java
Description
The following code shows how to get a BigInteger whose value is (this ^ exponent mod m).
Example
//from w w w . j av a2s.c o m
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws Exception {
BigInteger p = new BigInteger("2");
BigInteger g = new BigInteger("3");
BigInteger Ya = g.modPow(g, p);
System.out.println("Ya = " + Ya);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »