B: 256
pow()
public BigInteger pow( int exp )
Returns aBigInteger
whose value is the integer raised to the powerexp
. Throws anArithmeticException
ifexp
is negative.
Notice that the exponent is an int
, not a BigInteger
.
An int
can be as large as two billion and it is unlikely you will need an exponent larger than this.
Of course, an integer raised to an integer power results in an integer, so BigInteger
is the appropriate data type.
What would you do if you need to raise an integer to a non-integer power?