FACTORIAL Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
FACTORIAL Function
The FACTORIAL function returns an integer that is the factorial of
parameter-1. The function type is integer.
Syntax
FUNCTION FACTORIAL (parameter-1)
Parameters
parameter-1 Must be an integer greater than or equal to zero.
(The largest value parameter-1 can be is 20 in
order for the result to fit in 18 digits.)
Return Value
If the value of parameter-1 is zero, the value one is returned.
If the value of parameter-1 is positive, the factorial of parameter-1 is
returned.
Example
77 NUM-FACTORIAL PIC 9(5) VALUE ZERO.
:
COMPUTE NUM-FACTORIAL = FUNCTION FACTORIAL (4).
DISPLAY NUM-FACTORIAL.
The above example displays the following:
00024
MPE/iX 5.0 Documentation