factorial

(function for equations)

 

Usage:

factorial (n)

Definition:

n (n – 1) (n – 2) ... 1

Required:

n0      n is an integer

Returns the factorial of n, which is the product of the first n integers.

factorial(n) is often written as n!

factorial(0) = 1

Even fairly small values of n (around 170) can cause factorial to overflow.  For that reason calculations with the factorial function are often done using the logarithm of the results, for which you can use logfactorial.

If n is not an integer you may want to use the gamma function, which for integer values is related to factorial by: factorial (n) = gamma (n + 1) but which is also defined for non-integer values.