FACTORIAL

The FACTORIAL function computes the factorial N ! as the double-precision product, ( N ) ( N -1) ( N -2) ... 3 2 1.

This routine is written in the IDL language. Its source code can be found in the file factorial.pro in the lib subdirectory of the IDL distribution.

Calling Sequence

Result = FACTORIAL( N )

Arguments

N

A non-negative integer or long integer.

Note: large values of N will cause floating-point overflow errors. The maximum size of N varies with machine architecture. On machines that support the IEEE standard for floating-point arithmetic, the maximum value of N is 170. See MACHAR for a discussion of machine-specific parameters affecting floating-point arithmetic.

Keywords

STIRLING

Set this keyword to use Stirling's asymptotic formula to approximate N !:

where e is the base of the natural logarithm.

Example

Compute 20!.

PRINT, FACTORIAL(20)

IDL prints:

2.4329020e+18

See Also

BINOMIAL, TOTAL