Computes the factorial of an integer.

Namespace:  Meta.Numerics.Functions
Assembly:  Meta.Numerics (in Meta.Numerics.dll) Version: 1.4.0.0 (1.4.0.0)

Syntax

         
 C#  Visual Basic  Visual C++ 
public static double Factorial(
	int n
)
Public Shared Function Factorial ( _
	n As Integer _
) As Double
public:
static double Factorial(
	int n
)

Parameters

n
Int32
The argument, which must be non-negative.

Return Value

The factorial n!.

Remarks

The factorial of an integer n is the product of all integers from 1 to n.

Because n! becomes too large to be representable as a double-precision floating point number for quite moderate values of n, you may find it convenient to use the LogFactorial(Int32) in order to avoid overflow when computing expression in which large factorials will cancel with other large factors.

Exceptions

ExceptionCondition
System..::.ArgumentOutOfRangeException n is negative.

See Also