Class NumberTheory

    • Constructor Summary

      Constructors 
      Constructor Description
      NumberTheory()  
    • Method Summary

      Modifier and Type Method Description
      static double argmax​(double... numbers)
      Arg-Max function.
      static double argmin​(double... numbers)
      Arg-Min function.
      static java.lang.String convDecimal2OthBase​(double decimalNumber, int numeralSystemBase)
      Decimal number to other numeral system conversion with base between 1 and 36.
      static java.lang.String convDecimal2OthBase​(double decimalNumber, int numeralSystemBase, int format)
      Decimal number to other numeral system conversion with base between 1 and 36.
      static double convOthBase2Decimal​(double[] baseAndDigits)
      Other base to decimal conversion.
      static double convOthBase2Decimal​(double numeralSystemBase, double... digits)
      Other base to decimal conversion.
      static double convOthBase2Decimal​(int[] baseAndDigits)
      Other base to decimal conversion.
      static double convOthBase2Decimal​(int numeralSystemBase, int... digits)
      Other base to decimal conversion.
      static double convOthBase2Decimal​(java.lang.String numberLiteral)
      Other base (base between 1 and 36) number literal conversion to decimal number.
      static double convOthBase2Decimal​(java.lang.String numberLiteral, int numeralSystemBase)
      Other base (base between 1 and 36) number literal conversion to decimal number.
      static double digitAtPosition​(double number, double position)
      Digit at position - numeral system with base 10
      static double digitAtPosition​(double number, double position, double numeralSystemBase)
      Digit at position - numeral system with given base
      static int digitAtPosition​(long number, int position)
      Digit at position - numeral system with base 10
      static int digitAtPosition​(long number, int position, int numeralSystemBase)
      Digit at position - numeral system with given base
      static char digitChar​(int digitIndex)
      Character representing digit for numeral systems with base between 1 and 36.
      static int digitIndex​(char digitChar)
      Digit index based on digit character for numeral systems with base between 1 and 36.
      static java.lang.String fractionToString​(double[] fraction)
      Converts array representing fraction to fraction string representation.
      static double gcd​(double... numbers)
      Greatest common divisor (GCD)
      static double gcd​(double a, double b)
      Greatest common divisor (GCD)
      static long gcd​(long... numbers)
      Greatest common divisor (GCD)
      static long gcd​(long a, long b)
      Greatest common divisor (GCD)
      static double[][] getDistValues​(double[] array, boolean returnOrderByDescFreqAndAscOrigPos)
      Returns list of distinct values found in a given array.
      static int getNumeralSystemBase​(java.lang.String numberLiteral)
      Recognition of numeral system base in which number literal represents number.
      static long getToFractionInitSearchSize()
      Gets initial search size used by the toFraction method
      static double lcm​(double... numbers)
      Latest common multiply (LCM)
      static double lcm​(double a, double b)
      Latest common multiply (LCM)
      static long lcm​(long... numbers)
      Latest common multiply (LCM)
      static long lcm​(long a, long b)
      Latest common multiply (LCM)
      static double max​(double... numbers)
      Maximum function.
      static double max​(double a, double b)
      Maximum function.
      static double max​(Expression f, Argument index, double from, double to, double delta)
      Maximum value - iterative operator.
      static double min​(double... numbers)
      Minimum function.
      static double min​(double a, double b)
      Minimum function.
      static double min​(Expression f, Argument index, double from, double to, double delta)
      Minimum value - iterative operator.
      static double numberOfDigits​(double number)
      Number of digits needed to represent given number in base 10 numeral system.
      static double numberOfDigits​(double number, double numeralSystemBase)
      Number of digits needed to represent given number (its integer part) in numeral system with given base.
      static int numberOfDigits​(long number)
      Number of digits needed to represent given number in base 10 numeral system.
      static long numberOfDigits​(long number, long numeralSystemBase)
      Number of digits needed to represent given number in numeral system with given base.
      static double numberOfDistValues​(double... numbers)
      Returns number of unique values found the list of numbers
      static double numberOfPrimeFactors​(double number)
      Prime decomposition (prime factorization) - returns number of distinct prime factors
      static double piProduct​(Expression f, Argument index, double from, double to, double delta)
      Product operator
      static double primeCount​(double n)
      Prime counting function
      static long primeCount​(long n)
      Prime counting function
      static double primeFactorExponent​(double number, double id)
      Prime decomposition (prime factorization) - returns prime factor exponent
      static double[] primeFactors​(double number)
      Prime decomposition (prime factorization)
      static long[] primeFactors​(long number)
      Prime decomposition (prime factorization)
      static double primeFactorValue​(double number, double id)
      Prime decomposition (prime factorization) - returns prime factor value
      static double primeTest​(double n)
      Prime test
      static boolean primeTest​(long n)
      Prime test
      static double prod​(double... numbers)
      Numbers multiplication.
      static void setToFractionInitSearchSize​(long n)
      Sets initial search size for the toFraction method
      static double sigmaSummation​(Expression f, Argument index, double from, double to, double delta)
      Summation operator (SIGMA FROM i = a, to b, f(i) by delta
      static int[] sortAsc​(double[] array)
      Array sort - ascending - quick sort algorithm.
      static double sum​(double... numbers)
      Adding numbers.
      static double[] toFraction​(double value)
      Converts double value to its fraction representation.
      static java.lang.String toFractionString​(double value)
      Converts number to its fraction string representation.
      static double[] toMixedFraction​(double value)
      Converts double value to its mixed fraction representation.
      static java.lang.String toMixedFractionString​(double value)
      Converts number to its mixed fraction string representation.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_TO_FRACTION_INIT_SEARCH_SIZE

        public static final long DEFAULT_TO_FRACTION_INIT_SEARCH_SIZE
        See Also:
        Constant Field Values
    • Constructor Detail

      • NumberTheory

        public NumberTheory()
    • Method Detail

      • setToFractionInitSearchSize

        public static final void setToFractionInitSearchSize​(long n)
        Sets initial search size for the toFraction method
        Parameters:
        n - initial search size, has to be non-zero positive.
        See Also:
        toFraction(double)
      • getToFractionInitSearchSize

        public static final long getToFractionInitSearchSize()
        Gets initial search size used by the toFraction method
        Returns:
        initial search size used by the toFraction method
        See Also:
        toFraction(double)
      • min

        public static final double min​(double a,
                                       double b)
        Minimum function.
        Parameters:
        a - the a function parameter
        b - the b function parameter
        Returns:
        if a,b <> Double.NaN returns Math.min(a, b), otherwise returns Double.NaN.
      • min

        public static final double min​(double... numbers)
        Minimum function.
        Parameters:
        numbers - the a function parameter
        Returns:
        if each number form numbers <> Double.NaN returns the smallest number, otherwise returns Double.NaN.
      • argmin

        public static final double argmin​(double... numbers)
        Arg-Min function.
        Parameters:
        numbers - the a function parameter
        Returns:
        Returns the index of the first smallest number, otherwise returns Double.NaN.
      • max

        public static final double max​(double a,
                                       double b)
        Maximum function.
        Parameters:
        a - the a function parameter
        b - the b function parameter
        Returns:
        if a,b <> Double.NaN returns Math.max(a, b), otherwise returns Double.NaN.
      • max

        public static final double max​(double... numbers)
        Maximum function.
        Parameters:
        numbers - the a function parameter
        Returns:
        if each number form numbers <> Double.NaN returns the highest number, otherwise returns Double.NaN.
      • argmax

        public static final double argmax​(double... numbers)
        Arg-Max function.
        Parameters:
        numbers - the a function parameter
        Returns:
        Returns the index of the first biggest number, otherwise returns Double.NaN.
      • sortAsc

        public static final int[] sortAsc​(double[] array)
        Array sort - ascending - quick sort algorithm.
        Parameters:
        array - Array to be sorted
        Returns:
        Sorts array and additionally returns initial ordering swapped according to sorting order.
      • getDistValues

        public static final double[][] getDistValues​(double[] array,
                                                     boolean returnOrderByDescFreqAndAscOrigPos)
        Returns list of distinct values found in a given array.
        Parameters:
        array - The array
        returnOrderByDescFreqAndAscOrigPos - Indicator whether to apply final ordering based on descending value frequency and ascending initial position.
        Returns:
        List of values in the form of: first index - value index, second index: 0 - value, 1 - value count, 2 - minimal value position in original array
      • numberOfDistValues

        public static final double numberOfDistValues​(double... numbers)
        Returns number of unique values found the list of numbers
        Parameters:
        numbers - The list of numbers
        Returns:
        Number of unique values. If list is null or any Double.NaN is found then Double.NaN is returned.
      • gcd

        public static final long gcd​(long a,
                                     long b)
        Greatest common divisor (GCD)
        Parameters:
        a - the a function parameter
        b - the b function parameter
        Returns:
        GCD(a,b)
      • gcd

        public static final double gcd​(double a,
                                       double b)
        Greatest common divisor (GCD)
        Parameters:
        a - the a function parameter
        b - the b function parameter
        Returns:
        if a, b <> Double.NaN returns gcd( (int)Math.round(a),(int)Math.round(b) ), otherwise returns Double.NaN.
      • gcd

        public static final long gcd​(long... numbers)
        Greatest common divisor (GCD)
        Parameters:
        numbers - the numbers
        Returns:
        GCD(a_1,...,a_n) a_1,...,a_n in numbers
      • gcd

        public static final double gcd​(double... numbers)
        Greatest common divisor (GCD)
        Parameters:
        numbers - the numbers
        Returns:
        if each number form numbers <> Double.NaN returns GCD(a_1,...,a_n) a_1,...,a_n in numbers, otherwise returns Double.NaN.
      • lcm

        public static final long lcm​(long a,
                                     long b)
        Latest common multiply (LCM)
        Parameters:
        a - the a function parameter
        b - the b function parameter
        Returns:
        LCM(a,b)
      • lcm

        public static final double lcm​(double a,
                                       double b)
        Latest common multiply (LCM)
        Parameters:
        a - the a function parameter
        b - the b function parameter
        Returns:
        if a, b <> Double.NaN returns lcm( (int)Math.round(a), (int)Math.round(b) ), otherwise returns Double.NaN.
      • lcm

        public static final long lcm​(long... numbers)
        Latest common multiply (LCM)
        Parameters:
        numbers - the numbers
        Returns:
        LCM(a_1,...,a_n) a_1,...,a_n in numbers
      • lcm

        public static final double lcm​(double... numbers)
        Latest common multiply (LCM)
        Parameters:
        numbers - the numbers
        Returns:
        if each number form numbers <> Double.NaN returns LCM(a_1,...,a_n) a_1,...,a_n in numbers, otherwise returns Double.NaN.
      • sum

        public static final double sum​(double... numbers)
        Adding numbers.
        Parameters:
        numbers - the numbers
        Returns:
        if each number from numbers <> Double.NaN returns sum(a_1,...,a_n) a_1,...,a_n in numbers, otherwise returns Double.NaN.
      • prod

        public static final double prod​(double... numbers)
        Numbers multiplication.
        Parameters:
        numbers - the numbers
        Returns:
        if each number from numbers <> Double.NaN returns prod(a_1,...,a_n) a_1,...,a_n in numbers, otherwise returns Double.NaN.
      • primeTest

        public static final boolean primeTest​(long n)
        Prime test
        Parameters:
        n - The number to be tested.
        Returns:
        true if number is prime, otherwise false
      • primeTest

        public static final double primeTest​(double n)
        Prime test
        Parameters:
        n - The number to be tested.
        Returns:
        true if number is prime, otherwise false
      • primeCount

        public static final long primeCount​(long n)
        Prime counting function
        Parameters:
        n - number
        Returns:
        Number of primes below or equal x
      • primeCount

        public static final double primeCount​(double n)
        Prime counting function
        Parameters:
        n - number
        Returns:
        Number of primes below or equal x
      • sigmaSummation

        public static final double sigmaSummation​(Expression f,
                                                  Argument index,
                                                  double from,
                                                  double to,
                                                  double delta)
        Summation operator (SIGMA FROM i = a, to b, f(i) by delta
        Parameters:
        f - the expression
        index - the name of index argument
        from - FROM index = form
        to - TO index = to
        delta - BY delta
        Returns:
        summation operation (for empty summation operations returns 0).
      • piProduct

        public static final double piProduct​(Expression f,
                                             Argument index,
                                             double from,
                                             double to,
                                             double delta)
        Product operator
        Parameters:
        f - the expression
        index - the name of index argument
        from - FROM index = form
        to - TO index = to
        delta - BY delta
        Returns:
        product operation (for empty product operations returns 1).
        See Also:
        Expression, Argument
      • min

        public static final double min​(Expression f,
                                       Argument index,
                                       double from,
                                       double to,
                                       double delta)
        Minimum value - iterative operator.
        Parameters:
        f - the expression
        index - the name of index argument
        from - FROM index = form
        to - TO index = to
        delta - BY delta
        Returns:
        product operation (for empty product operations returns 1).
        See Also:
        Expression, Argument
      • max

        public static final double max​(Expression f,
                                       Argument index,
                                       double from,
                                       double to,
                                       double delta)
        Maximum value - iterative operator.
        Parameters:
        f - the expression
        index - the name of index argument
        from - FROM index = form
        to - TO index = to
        delta - BY delta
        Returns:
        product operation (for empty product operations returns 1).
        See Also:
        Expression, Argument
      • digitIndex

        public static final int digitIndex​(char digitChar)
        Digit index based on digit character for numeral systems with base between 1 and 36.
        Parameters:
        digitChar - Digit character (lower or upper case) representing digit in numeral systems with base between 1 and 36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z
        Returns:
        Returns digit index if digit char was recognized, otherwise returns -1.
      • digitChar

        public static final char digitChar​(int digitIndex)
        Character representing digit for numeral systems with base between 1 and 36.
        Parameters:
        digitIndex - Digit index between 0 and 35
        Returns:
        Digit character representing digit for numeral systems with base between 1 and 36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z. If digit index is put of range '?' is returned.
      • getNumeralSystemBase

        public static final int getNumeralSystemBase​(java.lang.String numberLiteral)
        Recognition of numeral system base in which number literal represents number. Examples: 2 for b2.1001 or b.1001, 1 for b1.111, 23 for b23.123afg 16 for b16.123acdf or h.123acdf.
        Parameters:
        numberLiteral - Number literal string. Base format: b1. b2. b. b3. b4. b5. b6. b7. b8. o. b9. b10. b11. b12. b13. b14. b15. b16. h. b17. b18. b19. b20. b21. b22. b23. b24. b25. b26. b27. b28. b29. b30. b31. b32. b33. b34. b35. b36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z
        Returns:
        If number literal fits numeral system definition then numeral system base is returned (base between 1 and 36), otherwise -1 is returned.
      • convOthBase2Decimal

        public static final double convOthBase2Decimal​(java.lang.String numberLiteral,
                                                       int numeralSystemBase)
        Other base (base between 1 and 36) number literal conversion to decimal number.
        Parameters:
        numberLiteral - Number literal in given numeral system with base between 1 and 36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z
        numeralSystemBase - Numeral system base, between 1 and 36
        Returns:
        Decimal number after conversion. If conversion was not possible the Double.NaN is returned.
      • convOthBase2Decimal

        public static final double convOthBase2Decimal​(java.lang.String numberLiteral)
        Other base (base between 1 and 36) number literal conversion to decimal number. Base specification included in number literal. Examples: 2 for b2.1001 or b.1001, 1 for b1.111, 23 for b23.123afg 16 for b16.123acdf or h.123acdf.
        Parameters:
        numberLiteral - Number literal string. Base format: b1. b2. b. b3. b4. b5. b6. b7. b8. o. b9. b10. b11. b12. b13. b14. b15. b16. h. b17. b18. b19. b20. b21. b22. b23. b24. b25. b26. b27. b28. b29. b30. b31. b32. b33. b34. b35. b36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z
        Returns:
        Decimal number after conversion. If conversion was not possible the Double.NaN is returned.
      • convOthBase2Decimal

        public static final double convOthBase2Decimal​(int numeralSystemBase,
                                                       int... digits)
        Other base to decimal conversion.
        Parameters:
        numeralSystemBase - Numeral system base has to be above 0.
        digits - List of digits
        Returns:
        Number after conversion. If conversion is not possible then Double.NaN is returned.
      • convOthBase2Decimal

        public static final double convOthBase2Decimal​(double numeralSystemBase,
                                                       double... digits)
        Other base to decimal conversion.
        Parameters:
        numeralSystemBase - Numeral system base has to be above 0.
        digits - List of digits
        Returns:
        Number after conversion. If conversion is not possible then Double.NaN is returned.
      • convOthBase2Decimal

        public static final double convOthBase2Decimal​(int[] baseAndDigits)
        Other base to decimal conversion.
        Parameters:
        baseAndDigits - Numeral system base and digits specification. Numeral system base is placed at index 0, rest of array is interpreted as digits. Numeral system base has to be above 0.
        Returns:
        Number after conversion. If conversion is not possible then Double.NaN is returned.
      • convOthBase2Decimal

        public static final double convOthBase2Decimal​(double[] baseAndDigits)
        Other base to decimal conversion.
        Parameters:
        baseAndDigits - Numeral system base and digits specification. Numeral system base is placed at index 0, rest of array is interpreted as digits. Numeral system base has to be above 0.
        Returns:
        Number after conversion. If conversion is not possible then Double.NaN is returned.
      • convDecimal2OthBase

        public static final java.lang.String convDecimal2OthBase​(double decimalNumber,
                                                                 int numeralSystemBase)
        Decimal number to other numeral system conversion with base between 1 and 36.
        Parameters:
        decimalNumber - Decimal number
        numeralSystemBase - Numeral system base between 1 and 36
        Returns:
        Number literal representing decimal number in given numeral numeral system. Digits 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z. If conversion was not possible the "NaN" string is returned.
      • convDecimal2OthBase

        public static final java.lang.String convDecimal2OthBase​(double decimalNumber,
                                                                 int numeralSystemBase,
                                                                 int format)
        Decimal number to other numeral system conversion with base between 1 and 36.
        Parameters:
        decimalNumber - Decimal number
        numeralSystemBase - Numeral system base between 1 and 36
        format - If 1 then always bxx. is used, i.e. b1. or b16. If 2 then for binary b. is used, for octal o. is used, for hexadecimal h. is used, otherwise bxx. is used where xx is the numeral system base specification.
        Returns:
        Number literal representing decimal number in given numeral numeral system. Base format: b1. b2. b. b3. b4. b5. b6. b7. b8. o. b9. b10. b11. b12. b13. b14. b15. b16. h. b17. b18. b19. b20. b21. b22. b23. b24. b25. b26. b27. b28. b29. b30. b31. b32. b33. b34. b35. b36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z If conversion was not possible the "NaN" string is returned.
      • numberOfDigits

        public static final int numberOfDigits​(long number)
        Number of digits needed to represent given number in base 10 numeral system.
        Parameters:
        number - The number
        Returns:
        Number of digits needed to represent given number in base 10 numeral system.
      • numberOfDigits

        public static final double numberOfDigits​(double number)
        Number of digits needed to represent given number in base 10 numeral system.
        Parameters:
        number - The number
        Returns:
        Number of digits needed to represent given number in base 10 numeral system. If number is NaN the NaN is returned. If number is infinite then Double.POSITIVE_INFINITY is returned.
      • numberOfDigits

        public static final long numberOfDigits​(long number,
                                                long numeralSystemBase)
        Number of digits needed to represent given number in numeral system with given base.
        Parameters:
        number - The number
        numeralSystemBase - Numeral system base above 0
        Returns:
        Returns number of digits. In case when numeralSystemBase is lower than 1 then -1 is returned.
      • numberOfDigits

        public static final double numberOfDigits​(double number,
                                                  double numeralSystemBase)
        Number of digits needed to represent given number (its integer part) in numeral system with given base.
        Parameters:
        number - The number
        numeralSystemBase - Numeral system base above 0
        Returns:
        Returns number of digits. In case when numeralSystemBase is lower than 1 then Double.NaN is returned. If number or numeralSystemBase is Double.NaN then Double.NaN is returned. If numeralSystemBase is infinite then Double.NaN is returned.
      • digitAtPosition

        public static final int digitAtPosition​(long number,
                                                int position,
                                                int numeralSystemBase)
        Digit at position - numeral system with given base
        Parameters:
        number - The number
        position - Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).
        numeralSystemBase - Base of numeral system - above 0
        Returns:
        Return digit at given position. If digit finding was not possible then -1 is returned.
      • digitAtPosition

        public static final int digitAtPosition​(long number,
                                                int position)
        Digit at position - numeral system with base 10
        Parameters:
        number - The number
        position - Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).
        Returns:
        Return digit at given position. If digit finding was not possible then -1 is returned.
      • digitAtPosition

        public static final double digitAtPosition​(double number,
                                                   double position,
                                                   double numeralSystemBase)
        Digit at position - numeral system with given base
        Parameters:
        number - The number
        position - Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).
        numeralSystemBase - Base of numeral system - above 0
        Returns:
        Return digit at given position. If digit finding was not possible then Double.NaN is returned.
      • digitAtPosition

        public static final double digitAtPosition​(double number,
                                                   double position)
        Digit at position - numeral system with base 10
        Parameters:
        number - The number
        position - Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).
        Returns:
        Return digit at given position. If digit finding was not possible then Double.NaN is returned.
      • primeFactors

        public static final long[] primeFactors​(long number)
        Prime decomposition (prime factorization)
        Parameters:
        number - Number to be decomposed
        Returns:
        List of prime factors (non-distinct)
      • primeFactors

        public static final double[] primeFactors​(double number)
        Prime decomposition (prime factorization)
        Parameters:
        number - Number to be decomposed
        Returns:
        List of prime factors (non-distinct)
      • numberOfPrimeFactors

        public static final double numberOfPrimeFactors​(double number)
        Prime decomposition (prime factorization) - returns number of distinct prime factors
        Parameters:
        number - Number to be decomposed
        Returns:
        Number of distinct prime factors
      • primeFactorValue

        public static final double primeFactorValue​(double number,
                                                    double id)
        Prime decomposition (prime factorization) - returns prime factor value
        Parameters:
        number - Number to be decomposed
        id - Factor id
        Returns:
        Factor value if factor id between 1 and numberOfPrimeFactors, otherwise 1 is returned. For NaN of infinite parameters Double NaN is returned. For number eq 0 Double.NaN is returned.
      • primeFactorExponent

        public static final double primeFactorExponent​(double number,
                                                       double id)
        Prime decomposition (prime factorization) - returns prime factor exponent
        Parameters:
        number - Number to be decomposed
        id - Factor id
        Returns:
        Factor exponent if factor id between 1 and numberOfPrimeFactors, otherwise 0 is returned. For NaN of infinite parameters Double NaN is returned. For number eq 0 Double.NaN is returned.
      • toFraction

        public static final double[] toFraction​(double value)
        Converts double value to its fraction representation.
        Parameters:
        value - Value to be converted
        Returns:
        Array representing fraction. Sign at index 0, numerator at index 1, denominator at index 2. If conversion is not possible then Double.NaN is assigned to all the fields.
      • toMixedFraction

        public static final double[] toMixedFraction​(double value)
        Converts double value to its mixed fraction representation.
        Parameters:
        value - Value to be converted
        Returns:
        Array representing fraction. Sign at index 0, whole number at index 1, numerator at index 2, denominator at index 3. If conversion is not possible then Double.NaN is assigned to both numerator and denominator.
      • fractionToString

        public static final java.lang.String fractionToString​(double[] fraction)
        Converts array representing fraction to fraction string representation.
        Parameters:
        fraction - Array representing fraction (including mix fractions)
        Returns:
        String representation of fraction.
        See Also:
        toFraction(double), toMixedFraction(double)
      • toFractionString

        public static final java.lang.String toFractionString​(double value)
        Converts number to its fraction string representation.
        Parameters:
        value - Given number
        Returns:
        String representation of fraction.
        See Also:
        toFraction(double), fractionToString(double[])
      • toMixedFractionString

        public static final java.lang.String toMixedFractionString​(double value)
        Converts number to its mixed fraction string representation.
        Parameters:
        value - Given number
        Returns:
        String representation of fraction.
        See Also:
        toMixedFraction(double), fractionToString(double[])