Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.gamma() Method

Python math.gamma() Method

Python math Module Python math Module

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:

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

print

(

math

.

gamma

(

0.1

)

)

print

(

math

.

gamma

(

8

)

)

print

(

math

.

gamma

(

1.2

)

)

print

(

math

.

gamma

(

80

)

)

print

(

math

.

gamma

(

0.55

)

)

Output result:


-10.686287021193193
5040.0
0.9181687423997604
8.946182130782976e+116
-3.578429819277059

Python math Module Python math Module