The math.gamma() function is used to calculate the Gamma function( Γ(x)) of a given number. The Gamma function is an extension of the factorial function it is defined by the following equation: Γ(x) = (x-1)!

However, there is an important distinction between gamma and factorials. While, factorials calculates the number of permutations when a partial arrangement is not allowed, Gamma function  is used to calculate the number of permutations when a partial arrangement is also allowed. A resulting effect is that we can get the gamma function of floating point values which is impossible with factorials.

Syntax:
math.gamma(x) 

Where, parameter x is a real number for which the Gamma function is to be calculated. 

This function returns the Gamma function of as a floating point value.

ExampleEdit & Run
import math 

print(math.gamma(3))
print(math.gamma(4))
print(math.gamma(5))
print(math.gamma(6))
print(math.gamma(2.5))
print(math.gamma(3.142))
print(math.gamma(math.e))
print(math.gamma(10.2567))
Output:
2.0 6.0 24.0 120.0 1.3293403881791372 2.2889488339454953 1.5674682557740531 649063.9928688111 [Finished in 0.010572416242212057s]