Java BigInteger gcd() method20 Mar 2025 | 2 min read The gcd() method of Java BigInteger class is used to get the greatest common divisor of absolute values of two BigInteger. This method returns a BigInteger whose value is the greatest common divisor of abs (this) and abs (val). Greatest Common Divisor:The greatest common divisor (gcd) of two or more integers which are not all zero, is the largest positive integer that divides each of the integers. For example, the gcd of 10 and 20 is 10 Syntax:Parameter:val - value with which the GCD is to be computed. Returns:This method returns GCD( abs(this) , abs(val) ) Exception:NA Note:
Example 1Output: GCD of 12 and 10 is 2 Example 2Output: GCD of -12 and -10 is 2 Example 3Output: GCD of 12 and 0 is 12 Next TopicJava BigInteger |
Java BigInteger Method The method of Java BigInteger class is used to find the Bitwise NOT of a BigInteger. This method returns a BigInteger whose value is ( ~this). Syntax: public BigInteger Parameter: NA Returns: This method returns ( ~this). Exception: NA Note: This method returns a negative value if and only...
1 min read
Java BigInteger Method The method of Java BigInteger class is used to find the Bitwise XOR of two BigIntegers. This method returns a BigInteger whose value is (this ^ val). Syntax: public BigInteger xor(BigInteger val) Parameter: val - value to be XOR'ed with this BigInteger. Returns: This method returns this...
2 min read
Java BigInteger method The 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: public BigInteger modInverse(BigInteger m) Parameter: m- the modulus. Returns: The method...
1 min read
Java BigInteger Method The method of Java BigInteger classreturns the bitwise AND of this BigInteger and the bitwise negation of the given BigInteger as a new BigInteger. Calling this method is equivalent to calling and (val.not()). Syntax: public BigInteger andNot(BigInteger val) Parameter: val - Value to be complemented...
1 min read
Java BigInteger method The method of Java BigInteger class is used to find a probably prime number of any bit length. This method returns a positive BigInteger that is probably prime, with the specified bitLength. Syntax: public static BigInteger probablePrime(int bitLength,Random rnd) Parameter: bitLength- bitLength of the...
3 min read
Java BigInteger method The 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: public...
2 min read
Java BigInteger Method The method of Java BigInteger class returns a BigInteger whose value is (this & val). Syntax: public BigInteger and(BigIntegerval) Parameter: val- A value to be AND'ed with this BigInteger. Returns: This method returns a BigInteger object of value, this &val . Note:This method returns a negative BigInteger if...
2 min read
Java BigInteger ProbablePrime() Method The ProbablePrime() method of Java BigInteger class is used to find the Prime Number greater than the current BigInteger. This method returns the first integer greater than this BigInteger that is probably prime. Syntax: public BigInteger ProbablePrime() Parameter: NA Returns: This method returns the first integer greater...
1 min read
Java BigInteger method The method of Java BigInteger class is used to calculate the power of BigInteger value. This method returns a BigInteger whose value is (thisexponent ). Syntax: public BigInteger pow(int exponent) Parameter: exponent- exponent to which this BigInteger is to be raised. Returns: This method returns (thisexponent...
1 min read
Java BigInteger method The method of Java BigInteger class is used to convert this BigInteger to a long.This conversion is similar to the narrowing primitive conversion from long to int. Narrowing Primitive Conversion: According to The Java Language Specification, it is defined as ifthisBigInteger has too...
2 min read
We request you to subscribe our newsletter for upcoming updates.
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