Click or drag to resize

CombinatoricFactorial Method

Returns the factorial of the supplied value.

Namespace:  Kaos.Combinatorics
Assembly:  KaosCombinatorics (in KaosCombinatorics.dll) Version: 6.0.0.0
Syntax
C#
public static long Factorial(
	int value
)

Parameters

value
Type: SystemInt32
Non-negative integer.

Return Value

Type: Int64
For increasing value starting at 0, returns 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000, 2432902008176640000.
Exceptions
ExceptionCondition
IndexOutOfRangeExceptionWhen value not in range (0..20).
Examples

The number of rows in a Permutation table of n choices is:

Combinatoric.Factorial (n)

The number of rows in a Permutation table of k picks from n choices is:

Combinatoric.Factorial (n) / Combinatoric.Factorial (n-k)

An exception to the above formulas is the special case where the number of elements in the permutation is 0. While mathematics treats this result as 1 row containing the empty product, this library returns 0 rows.

See Also