Open In App

Compute the Natural Logarithm of Factorial in R Programming – lfactorial() Function

Last Updated : 10 Jun, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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'

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads