jax.scipy.special.factorial(n, exact=False)[source]#

The factorial of a number or array of numbers.

LAX-backend implementation of scipy.special.factorial().

Original docstring below.

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
  • n (int or array_like of ints) – Input values. If n < 0, the return value is 0.

  • exact (bool, optional) – 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.


nf – Factorial of n, as integer or float depending on exact.

Return type:

float or int or ndarray