Java calculate the value of a BigInteger to the power of a number

Tags: BigInteger BigInteger pow

In this Java core tutorial we learn how to use the java.math.BigInteger.pow() method to calculate the value of a given BigInteger value to the power of an integer number.

How to calculate pow of BigInteger value

In the Java program below we show you how to use the java.math.BigInteger.pow() method.

PowBigIntegerExample.java

import java.math.BigInteger;

public class PowBigIntegerExample {
    public static void main(String... args) {
        BigInteger value = new BigInteger("123456789");
        int exponent = 10;

        BigInteger result = value.pow(exponent);

        System.out.println(value + " pow " + exponent + " = " + result);
    }
}
The output is:
123456789 pow 10 = 822526259147102579504761143661535547764137892295514168093701699676416207799736601

Happy Coding 😊