Java BigInteger modInverse() methodThe modInverse() method of Java BigInteger class is used to find the modulus of the inverse of this BigInteger value. This method returns a BigInteger whose value is inverse of this BigInteger mod parameter value. Syntax:Parameter:m- the modulus. Returns:The method returns (this-1 mod m). Exception:ArithmeticException - if(m ≤ 0). Note: This method throws an ArithmeticException if the inverse of this BigInteger does not exist (that is, this BigInteger is not relatively prime to parameter value).Example 1Test it NowOutput: 13^-1 % 5 is 2 Example 2Test it NowOutput: -13^-1 % 5 is 3 Example 3Test it NowOutput: java.lang.ArithmeticException: BigInteger: modulus not positive Example 4Test it NowOutput: java.lang.ArithmeticException: BigInteger: modulus not positive 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