Python in its language allows various mathematical operations, which has manifolds application in scientific domain. One such offering of Python is the inbuilt
gamma() function, which numerically computes the gamma value of the number that is passed in the function.
Syntax : math.gamma(x)
x : The number whose gamma value needs to be computed.
Returns : The gamma value, which is numerically equal to “factorial(x-1)”.
Code #1 : Demonstrating the working of gamma()
The gamma value of the given argument is : 120.0
The gamma value can also be found using
factorial(x-1), but the use case of
gamma() is because, if we compare both the function to achieve the similar task,
gamma() offers better performance.
Code #2 : Comparing
The gamma value using factorial is : 120 The time taken to compute is : 9.059906005859375e-06 The gamma value using gamma() is : 120.0 The time taken to compute is : 5.245208740234375e-06
- Python math library | exp() method
- Python math library | expm1() method
- Python math library | isclose() method
- Python math library | isnan() method
- Python math library | isfinite() and remainder() method
- Python | sympy.gamma() method
- scipy stats.gamma() | Python
- Inverse Gamma Distribution in Python
- Python | math.gcd() function
- Python | math.sin() function
- Python | math.cos() function
- Python | math.tan() function
- Python math function | copysign()
- Python | math.copysign() function
- Python | math.factorial() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.