Factorial Module

Functions for computing the factorial of a number. The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n: n! = n * (n-1) * (n-2) * ... * 2 * 1 For example, 5! = 5 * 4 * 3 * 2 * 1 = 120 The value of 0! is 1.

Functions and values

Function or value Description

_factorialLn x

Full Usage: _factorialLn x

Parameters:
    x : int - The input to compute x!

Returns: float

Computes the natural logarithm of the factorial. Values will be approximated for x greather than 170, as the approximated _gammaLn function is used to obtain the results for large inputs. The caller is responsible to handle edge cases such as nan, infinity, and -infinity in the input

x : int

The input to compute x!

Returns: float

factorial x

Full Usage: factorial x

Parameters:
    x : int - The input to compute x!

Returns: float

Computes the factorial of integers less than 170. The factorial functions takes an int x and returns x!. This function will not overflow the floating point format as long as x is at most 170, and will return +infinity for all values greather than 170

x : int

The input to compute x!

Returns: float

factorialLn x

Full Usage: factorialLn x

Parameters:
    x : int - The input to compute x!

Returns: float

Computes the natural logarithm of the factorial. Values will be approximated for x greather than 170, as the approximated _gammaLn function is used to obtain the results for large inputs. Edge cases in the input (nan, infinity, and -infinity) are catched and handled. This might be slower than the unchecked version `_factorialLn` but does not require input sanitation to get expected results for these cases.

x : int

The input to compute x!

Returns: float