factorial(n, exact=False)
The factorial of non-negative integer n
is the product of all positive integers less than or equal to n
:
n! = n * (n - 1) * (n - 2) * ... * 1
For arrays with exact=True
, the factorial is computed only once, for the largest input, with each other result computed in the process. The output dtype is increased to int64
or object
if necessary.
With exact=False
the factorial is approximated using the gamma function:
Input values. If n < 0
, the return value is 0.
If True, calculate the answer exactly using long integer arithmetic. If False, result is approximated in floating point rapidly using the gamma
function. Default is False.
The factorial of a number or array of numbers.
>>> from scipy.special import factorial
... arr = np.array([3, 4, 5])
... factorial(arr, exact=False) array([ 6., 24., 120.])
>>> factorial(arr, exact=True) array([ 6, 24, 120])
>>> factorial(5, exact=True) 120See :
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.special._basic.factorial
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them