R语言 计算阶乘的自然对数 – lfactorial() 函数 R语言中的 lfactorial() 函数用于计算x的阶乘的自然对数,即ln(x!) 。 语法: lfactorial(x) 参数: x: 正数值 例1 : # R program to illustrate # lfactorial function # Calling the lfactorial() function lfactorial(0) lfactorial(1) lfactorial(5) RCopy 输出 [1] 0 [1] 0 [1] 4.787492 RCopy 例2 : # R program to illustrate # lfactorial function # Calling the lfactorial() function lfactorial(-4) RCopy 输出 [1] Inf Warning message: In lfactorial(-4) : value out of range in 'lgamma' RCopy