lnFactorial

Computes the natural logarithm of n factorial.

The logarithmic form avoids overflow for large n by delegating to lnGamma(n + 1). Returns 0.0 for n = 0 and n = 1 (since 0! = 1! = 1).

Example:

lnFactorial(0)  // 0.0 (ln(1))
lnFactorial(5) // 4.7874... (ln(120))
lnFactorial(20) // 42.3356... (ln(20!), no overflow)

Return

the natural logarithm of n!.

Parameters

n

the non-negative integer whose factorial logarithm to compute.