Problem Statement
You need to calculate the power of a number of type BigInteger in Java.
Solution
Use the instance method “pow” of the type BigInteger by passing the exponent which will return the power as shown below.
import java.math.BigInteger; public class abundantcodeconsole { public static void main(String[] args) { BigInteger input1 = new BigInteger("2987569"); int exponent = 3; BigInteger result = input1.pow(exponent); System.out.println(result); } }
The output of the above program is
26665751846889541009
Leave a Reply