Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

FACTORIAL - Factorial

The FACTORIAL function returns an integer that is the factorial of argument-1.
The type of this function is integer.

Format


FUNCTION FACTORIAL (argument-1)


Argument

  1. argument-1 must be an integer greater than or equal to zero and less than or equal to 29.

Returned values

  1. If the value of argument-1 is zero, the value 1 is returned.

  2. If the value of argument-1 is positive, its factorial is returned.

  3. The error default value is -2.


See also:        LOG, LOG10, SQRT

Example 9-15

...
DATA DIVISION.
WORKING-STORAGE SECTION.
01  RES PIC 9(8).
PROCEDURE DIVISION.
P1 SECTION.
MAIN.
    COMPUTE RES = FUNCTION FACTORIAL (07).
    DISPLAY RES UPON T.
    STOP RUN. 

Result:               00005040