Class Factorial

java.lang.Object
org.apache.commons.numbers.combinatorics.Factorial

public final class Factorial extends Object
  • Method Details

    • value

      public static long value(int n)
      Computes the factorial of n.
      Parameters:
      n - Argument.
      Returns:
      n!
      Throws:
      IllegalArgumentException - if n < 0.
      IllegalArgumentException - if n > 20 (the factorial value is too large to fit in a long).
    • doubleValue

      public static double doubleValue(int n)
      Computes the factorial of n.

      The result should be small enough to fit into a double: The largest n for which n! does not exceed Double.MAX_VALUE is 170. Double.POSITIVE_INFINITY is returned for n > 170.

      Parameters:
      n - Argument.
      Returns:
      n!
      Throws:
      IllegalArgumentException - if n < 0.
      Since:
      1.1