Python math.gamma() Method
Python math.gamma(x) The method returns the Gamma function at x.
The Gamma function, also called Euler's second integral, is a class of functions that extends the factorial function to real and complex numbers.
To find the log-gamma value of a number, use math.lgamma() method.
Python version: 3.2
Syntax
The syntax of the math.gamma() method is as follows:
math.gamma(x)
Parameter Description:
- x -- required, a number. If the number is a negative integer, a ValueError is returned. If it is not a number, a TypeError is returned.
Return Value
A floating-point value representing the Gamma function at x.
Example
The following example computes the Gamma function of different numbers:
Example
Import the math package
import
math
Compute the Gamma function of different numbers
(
math
.
gamma
(
0.1
)
)
(
math
.
gamma
(
8
)
)
(
math
.
gamma
(
1.2
)
)
(
math
.
gamma
(
80
)
)
(
math
.
gamma
(
0.55
)
)
Output result:
-10.686287021193193
5040.0
0.9181687423997604
8.946182130782976e+116
-3.578429819277059
Python math Module