The problem is that you just passed a range that allows an integer.
Int allow numbers from -2,147,483,648 to the maximum value of 2,147,483,647 (inclusive) ( source ), since 74^5 = 2,219,006,624 . Thus, more than Int can handle.
If you want to use a wider range, you can use the java BigInteger Class. Code example:
BigInteger pow(BigInteger base, BigInteger exponent) { BigInteger result = BigInteger.ONE; while (exponent.signum() > 0) { if (exponent.testBit(0)) result = result.multiply(base); base = base.multiply(base); exponent = exponent.shiftRight(1); } return result; }
Considerations: This may not be very effective and may not work for negative reasons or indicators. Use it as an example of how to use BigIntegers.
Instead of BigInteger, you can also use the long type, which ranges from 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (inclusive) ( source ).
Do not use double for this purpose, as you may have problems.