Factorial for , computed by direct multiplication.
Returns: as a double-precision real (avoids integer overflow
for moderate K; see LOG_FACT for large-K stability).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i4), | intent(in) | :: | K |
Non-negative integer argument. |
FUNCTION FACTORIAL_DP(K) RESULT(FACTORIAL) IMPLICIT NONE INTEGER(KIND=i4), INTENT(IN) :: K REAL(KIND=dp) :: FACTORIAL INTEGER(KIND=i4) :: I FACTORIAL = 1.0d0 DO I = 1,K FACTORIAL = I * FACTORIAL END DO RETURN END FUNCTION FACTORIAL_DP