Click or drag to resize

Fact Function

X#
Calculate the factorial of a number.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION Fact(
	wValue AS DWORD
) AS FLOAT
Request Example View Source

Parameters

wValue
Type: DWord
A positive number.

Return Value

Type: Float
Remarks
The factorial of an integer n is computed as follows:
X#
1Factorial(n)=n*(n-1)*(n-2) ... 3*2*1
The factorial of 0 is defined to be 1.
Examples
This example uses Fact() to compute the factorial of 5, then it verifies the result:
X#
1? Fact(5)                    // 120
2// Verify
3? 5*4*3*2*1                    // 120
See Also