Java BigInteger modPow() methodThe modPow() method of Java BigInteger class is used to perform modular exponentiation. This method returns a BigInteger whose value is (thisexponent mod parameter value). This method first calculates the pow() method then applies the mod() method. This method allows negative exponents. Syntax:Parameter:exponent- The Exponent. m- The modulus. Returns:This method returns (thisexponent mod m). Exception:ArithmeticException - m ≤ 0 Example 1Test it NowOutput: 13^2 mod 5 is 4 Example 2Test it NowOutput: java.lang.ArithmeticException: BigInteger: modulus not positive Example 3Test it NowOutput: 13^-2 mod 5 is 4 Example 4Test it NowOutput: -13^-2 mod 5 is 4 Next TopicJava BigInteger |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India