Compute the Natural Logarithm of Factorial in R Programming – lfactorial() Function
lfactorial()
function in R Language is used to compute the natural logarithm of factorial of x i.e, ln(x!).
Syntax: lfactorial(x)
Parameters:
x: positive numeric value
Example 1:
# R program to illustrate # lfactorial function # Calling the lfactorial() function lfactorial( 0 ) lfactorial( 1 ) lfactorial( 5 ) |
Output:
[1] 0 [1] 0 [1] 4.787492
Example 2:
# R program to illustrate # lfactorial function # Calling the lfactorial() function lfactorial( - 4 ) |
Output:
[1] Inf Warning message: In lfactorial(-4) : value out of range in 'lgamma'
Contact Us