COBOL Manual for TNS and TNS/R Programs
Intrinsic Functions
HP COBOL Manual for TNS and TNS/R Programs—522555-006
14-19
FACTORIAL Function
FACTORIAL Function
FACTORIAL, an integer function, returns the factorial of its argument.
argument
is an integer greater than or equal to zero.
When argument is zero, the returned value is 1; when argument is positive, the
returned value is its factorial.
Example 14-11. FACTORIAL Function
Code:
DISPLAY FUNCTION FACTORIAL (0)
DISPLAY FUNCTION FACTORIAL (1)
DISPLAY FUNCTION FACTORIAL (4)
DISPLAY FUNCTION FACTORIAL (6)
DISPLAY FUNCTION FACTORIAL (10)
Output:
0000000000000000001
0000000000000000001
0000000000000000024
0000000000000000720
0000000000003628800
( )
FACTORIALFUNCTION argument
VST430.vsd