Here, We will learn how to get the natural logarithm and sign (-1 or +1) of Gamma(x) in go. We can get it by using Lgamma() function in math package in go golang.
Function prototype:
func Lgamma(n float64) (lgamma float64, sign int)
Return value:
Lgamma() function in math package returns
the natural logarithm and sign (-1 or +1)
of Gamma(n).
Example with code:
package main
import (
"fmt"
"math"
)
func main() {
no, sign := math.Lgamma(1.2)
fmt.Println(no, sign)
no, sign = math.Lgamma(2.3)
fmt.Println(no, sign)
no, sign = math.Lgamma(0.0)
fmt.Println(no, sign)
no, sign = math.Lgamma(-2.9)
fmt.Println(no, sign)
}
Output:
-0.08537409000331386 1
0.15418945495963046 1
+Inf 1
0.6515085442272082 -1
To learn more about golang, Please refer given below link:
https://www.techieindoor.com/go-lang-tutorial/
References:
https://golang.org/doc/
https://golang.org/pkg/