next up previous contents
Next: The Floor Function Up: Mathematical Functions Previous: The Exponential Function

The Factorial Function

Calling Sequence:
factorial(
x)
x!
Parameters:
x : { posint, 0}

Returns: posint

Synopsis: Returns the result of the factorial function:

\begin{displaymath}factorial(x) = \left\{ \begin{array}{ll}
x \cdot factorial(x-1) & \mbox{if $x>0$ } \\
1 & otherwise
\end{array} \right.
\end{displaymath}

Large values of x are approximated by a variant of the gamma function. References: [1]

Examples:

> factorial(0);
> factorial(5);
> factorial(120);




Gaston Gonnet
1998-09-15