Class BigIntegerUtil


  • public final class BigIntegerUtil
    extends Object
    Since:
    1.0
    • Method Detail

      • gcd

        public static BigInteger gcd​(BigInteger[] integers,
                                     int from,
                                     int to)
        Returns the greatest common an array of longs
        Parameters:
        integers - array of longs
        from - from position (inclusive)
        to - to position (exclusive)
        Returns:
        greatest common divisor of array
      • pow

        public static BigInteger pow​(long base,
                                     long exponent)
        Returns base in a power of e (non negative)
        Parameters:
        base - base
        exponent - exponent (non negative)
        Returns:
        base in a power of e
        Throws:
        ArithmeticException - if the result overflows a long
      • pow

        public static BigInteger pow​(BigInteger base,
                                     long exponent)
        Returns base in a power of e (non negative)
        Parameters:
        base - base
        exponent - exponent (non negative)
        Returns:
        base in a power of e
        Throws:
        ArithmeticException - if the result overflows a long
      • pow

        public static BigInteger pow​(BigInteger base,
                                     int exponent)
        Returns base in a power of e (non negative)
        Parameters:
        base - base
        exponent - exponent (non negative)
        Returns:
        base in a power of e
        Throws:
        ArithmeticException - if the result overflows a long
      • pow

        public static BigInteger pow​(BigInteger base,
                                     BigInteger exponent)
        Returns base in a power of e (non negative)
        Parameters:
        base - base
        exponent - exponent (non negative)
        Returns:
        base in a power of e
        Throws:
        ArithmeticException - if the result overflows a long
      • perfectPowerDecomposition

        public static BigInteger[] perfectPowerDecomposition​(BigInteger n)
        Tests whether n is a perfect power n == a^b and returns {a, b} if so and null otherwise
        Parameters:
        n - the number
        Returns:
        array {a, b} so that n = a^b or null is n is not a perfect power
      • factorial

        public static BigInteger factorial​(int number)
        Factorial of a number
      • binomial

        public static BigInteger binomial​(int n,
                                          int k)
        Binomial coefficient