This function evaluates the factorial of the argument.
FAC — Function
value. (Output)
See Comment 1.
N — Argument for which the factorial is desired. (Input)
Specific: The specific interface names are S_FAC and D_FAC.
Double: The double precision function name is DFAC.
The factorial is computed using the relation n! = G(n + 1). The function G(x) is defined in GAMMA. The argument n must be greater than or equal to zero, and it must not be so large that n! overflows. Approximately, n! overflows when nne−n overflows.
If the generic version of this function is used, the immediate result must be stored in a variable before use in an expression. For example:
X = FAC(6)
Y =
SQRT(X)
must be used rather than
If this is too much of a restriction on the programmer, then the specific name can be used without this restriction.
To evaluate the factorial for nonintegral values of the argument, the gamma function should be used. For large values of the argument, the log gamma function should be used.
In this example, 6! is computed and printed.
99999 FORMAT (' FAC(', I1, ') = ', F6.2)
|
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |