Skip to content

Tag Archives: Java-BigInteger

Given a large number N, the task is to divide this number into a product of two factors, using Fermat’s Factorisation method. Examples Input: N… Read More
The java.math.BigInteger.sqrtAndRemainder() method performs an operation upon the current BigInteger by which this method is called. This method is used to calculate the integer square… Read More
The java.math.BigInteger.divide(BigInteger val) is used to calculate the division of two BigIntegers. BigInteger class internally uses array of integers for processing, the operation on object… Read More
The java.math.BigInteger.multiply(BigInteger val) is used to calculate the multiplication of two BigIntegers. As BigInteger class internally uses an array of integers for processing, the operation… Read More
The java.math.BigInteger.subtract(BigInteger val) is used to calculate the Arithmetic difference of two BigIntegers. This method is applicable on large value numbers of range much greater… Read More
The java.math.BigInteger.nextProbablePrime() is used to find the first integer greater than this BigInteger that is probably prime. If this method returns ‘p’ then there is… Read More
The java.math.BigInteger.add(BigInteger val) is used to calculate the Arithmetic sum of two BigIntegers. This method is used to find arithmetic addition of large numbers of… Read More
GCD (Greatest Common Divisor) or HCF (Highest Common Factor) of two numbers is the largest number that divides both of them. The java.math.BigInteger.gcd(BigInteger val) method… Read More
The java.math.BigInteger.isProbablePrime(int certainty) method is used to tell if this BigInteger is probably prime or if it’s definitely composite. This method checks for prime or… Read More
Given a positive integer n, the task is to find the sum of the first n natural numbers given that n is very large (1… Read More
The method divide(BigInteger p, BigInteger q, RoundingMode mode) of Guava’s BigIntegerMath class returns the result of dividing p by q, rounding using the specified RoundingMode.… Read More
The ceilingPowerOfTwo(BigInteger x) method of Guava’s BigIntegerMath class returns the smallest power of two greater than or equal to x. This is equivalent to BigInteger.valueOf(2).pow(log2(x,… Read More
The binomial(int n, int k) method of Guava’s BigIntegerMath class returns n choose k, also known as the binomial coefficient of n and k, that… Read More
The method sqrt(BigInteger x, RoundingMode mode) of Guava’s BigIntegerMath class returns the square root of x, rounded with the specified rounding mode. Syntax: public static… Read More
The method log2(BigInteger x, RoundingMode mode) of Guava’s BigIntegerMath class returns the base-2 logarithm of x, rounded according to the specified rounding mode. Syntax: public… Read More