math.Gamma() Function in Golang With Examples Last Updated : 13 Apr, 2020 Comments Improve Suggest changes Like Article Like Report Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You can find the Gamma function the given value with the help of the Gamma() function provided by the math package. So, you need to add a math package in your program with the help of the import keyword to access the Gamma() function. Syntax: func Gamma(a float64) float64 If Gamma(+Inf), then this method will return +Inf. If Gamma(+0), then this method will return +Inf. If Gamma(-Inf), then this method will return -Inf. If Gamma(a), then this method will return NaN for integer a<0. If Gamma(-Inf), then this method will return NaN. If Gamma(NaN), then this method will return NaN. Example 1: C // Golang program to illustrate // the math.Gamma() function package main import ( "fmt" "math" ) // Main function func main() { // Finding gamma function // of the given values. // Using Gamma() function res_1 := math.Gamma(math.Inf(-1)) res_2 := math.Gamma(math.Inf(1)) res_3 := math.Gamma(0) res_4 := math.Gamma(1) res_5 := math.Gamma(math.NaN()) // Displaying the result fmt.Printf("\nResult 1: %.1f", res_1) fmt.Printf("\nResult 2: %.1f", res_2) fmt.Printf("\nResult 3: %.1f", res_3) fmt.Printf("\nResult 4: %.1f", res_4) fmt.Printf("\nResult 5: %.1f", res_5) } Output: Result 1: NaN Result 2: +Inf Result 3: +Inf Result 4: 1.0 Result 5: NaN Example 2: C // Golang program to illustrate // the math.Gamma() function package main import ( "fmt" "math" ) // Main function func main() { // Finding gamma function // of the given values. // Using Gamma() function nvalue_1 := math.Gamma(2) nvalue_2 := math.Gamma(4) // Sum of the given numbers res := nvalue_1 + nvalue_2 fmt.Printf("%.2f + %.2f = %.2f", nvalue_1, nvalue_2, res) } Output: 1.00 + 6.00 = 7.00 Comment More infoAdvertise with us Next Article math.Gamma() Function in Golang With Examples K Kirti_Mangal Follow Improve Article Tags : Go Language Golang-Math Similar Reads math.Jn() Function in Golang With Examples Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You can find the order-n Bessel function of the first kind with the help of Jn() function provided by the math package. So, you need to add a ma 2 min read math.J0() Function in Golang With Examples Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You can find the order-zero Bessel function of the first kind with the help of J0() function provided by the math package. So, you need to add a 2 min read math.J1() Function in Golang With Examples Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You can find order-one Bessel function of the first kind with the help of J1() function provided by the math package. So, you need to add a math 2 min read math.Yn() Function in Golang With Examples Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You can the order-n Bessel function of the second kind the help of Yn() function provided by the math package. So, you need to add a math packag 2 min read math.Y0() Function in Golang With Examples Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You can find the order-zero Bessel function of the second kind with the help of Y0() function provided by the math package. So, you need to add 2 min read math.Y1() Function in Golang With Examples Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You can find the order-one Bessel function of the second kind with the help of Y1() function provided by the math package. So, you need to add a 2 min read math.Inf() Function in Golang With Examples Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You can find positive infinity (if sign >= 0) or negative infinity (if sign < 0) with the help of the Inf() function provided by the math 2 min read math.Pow() Function in Golang With Examples Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You can find the base-a exponential of b(a**b)with the help of Pow() function provided by the math package. So, you need to add a math package i 3 min read math.Dim() Function in Golang With Examples Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. Dim() function provided by the math package return the maximum of a-b or 0. So, to access this function you need to add a math package in your p 2 min read math.NaN() Function in Golang With Examples Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You get an IEEE 754 "not-a-number" value with the help of NaN() function provided by the math package. So, you need to add a math package in you 1 min read Like