Ma · Mathematics

How to Calculate the Factorial of a Noninteger

Published By the 9to5Science editorial team

At a glance

  1. 1. Extend the definition

    Use the Gamma function: x! is defined as Γ(x + 1).

  2. 2. Use the integral

    For positive x, evaluate Γ(x + 1) with its defining integral.

  3. 3. Apply recurrence

    Reduce half-integer or other convenient values using Γ(z + 1) = zΓ(z).

  4. 4. Check special cases

    Remember that nonpositive integers are poles, so their generalized factorials are undefined.

The usual factorial is defined for nonnegative integers by

n!=1⋅2⋅3⋯n.n! = 1\cdot 2\cdot 3\cdots n.

That product does not directly make sense when nn is, for example, 1/21/2 or 2.32.3. The standard extension is the Gamma function:

x!=Γ(x+1).x! = \Gamma(x+1).

This definition agrees with ordinary factorials and supplies a smooth value for most noninteger inputs.

The Gamma function definition

For z>0z>0, the Gamma function can be defined by the improper integral

Γ(z)=∫0∞tz−1e−t dt.\Gamma(z) = \int_0^\infty t^{z-1}e^{-t}\,dt.

Therefore, for a positive real number xx,

x!=Γ(x+1)=∫0∞txe−t dt.x! = \Gamma(x+1) = \int_0^\infty t^x e^{-t}\,dt.

The Gamma function satisfies the recurrence relation

Γ(z+1)=zΓ(z).\Gamma(z+1)=z\Gamma(z).

Since Γ(1)=1\Gamma(1)=1, this gives

Γ(n+1)=n(n−1)⋯2⋅1 Γ(1)=n!\Gamma(n+1)=n(n-1)\cdots 2\cdot 1\,\Gamma(1)=n!

for every nonnegative integer nn. Thus the Gamma function is not a different answer for integer factorials; it is the standard extension of the same operation.

Worked example: the factorial of one-half

Set x=1/2x=1/2. Then

(12)!=Γ(32).\left(\frac12\right)! = \Gamma\left(\frac32\right).

Use the recurrence relation:

Γ(32)=12Γ(12)=12π.\begin{aligned} \Gamma\left(\frac32\right) &=\frac12\Gamma\left(\frac12\right)\\ &=\frac12\sqrt{\pi}. \end{aligned}

The identity Γ(1/2)=π\Gamma(1/2)=\sqrt{\pi} follows from the Gaussian integral. Hence

(12)!=π2≈0.8862269255.\boxed{\left(\frac12\right)! = \frac{\sqrt{\pi}}{2} \approx 0.8862269255.}

Notice that this value is not obtained by trying to multiply all numbers from 11 to 1/21/2. The Gamma function supplies the meaningful extension.

Worked example: the factorial of 3.5

For x=3.5=7/2x=3.5=7/2,

3.5!=Γ(4.5)=Γ(92).3.5! = \Gamma(4.5)=\Gamma\left(\frac92\right).

Apply the recurrence repeatedly:

Γ(92)=72Γ(72)=72⋅52Γ(52)=72⋅52⋅32Γ(32)=72⋅52⋅32⋅12Γ(12)=10516π.\begin{aligned} \Gamma\left(\frac92\right) &=\frac72\Gamma\left(\frac72\right)\\ &=\frac72\cdot\frac52\Gamma\left(\frac52\right)\\ &=\frac72\cdot\frac52\cdot\frac32\Gamma\left(\frac32\right)\\ &=\frac72\cdot\frac52\cdot\frac32\cdot\frac12\Gamma\left(\frac12\right)\\ &=\frac{105}{16}\sqrt{\pi}. \end{aligned}

Therefore,

3.5!=105π16≈11.6317283966.\boxed{3.5! = \frac{105\sqrt{\pi}}{16} \approx 11.6317283966.}

More generally, for a nonnegative integer nn,

(n+12)!=Γ(n+32)=(2n+1)!!2n+1π,\left(n+\frac12\right)! = \Gamma\left(n+\frac32\right) =\frac{(2n+1)!!}{2^{n+1}}\sqrt{\pi},

where (2n+1)!!=1⋅3⋅5⋯(2n+1)(2n+1)!!=1\cdot3\cdot5\cdots(2n+1) is an odd double factorial.

Calculating an arbitrary decimal factorial

For a value such as 2.32.3, there is usually no simple expression involving elementary functions. Use a numerical implementation of the Gamma function:

2.3!=Γ(3.3)≈2.6834373819.2.3! = \Gamma(3.3) \approx 2.6834373819.

Scientific calculators may have a Gamma function button, often written as Γ, gamma, or GAMMA. In a programming language, use its standard special-function library. For example, Python’s math.gamma gives the generalized factorial directly:

import math

x = 2.3
print(math.gamma(x + 1))

This prints approximately 2.6834373819.

For large arguments, computing the factorial itself can overflow ordinary numerical types. In that situation, use the logarithmic Gamma function instead:

log⁡(x!)=log⁡Γ(x+1).\log(x!)=\log\Gamma(x+1).

In Python, this is available as math.lgamma(x + 1).

What happens for negative nonintegers?

The Gamma function extends the factorial beyond positive numbers as well. For example,

(−12)!=Γ(12)=π.\left(-\frac12\right)! = \Gamma\left(\frac12\right)=\sqrt{\pi}.

However, Γ(z)\Gamma(z) has poles at z=0,−1,−2,…z=0,-1,-2,\ldots. Since x!=Γ(x+1)x!=\Gamma(x+1), the generalized factorial is undefined when

x+1=0,−1,−2,…, x+1=0,-1,-2,\ldots,

that is, when x=−1,−2,−3,…x=-1,-2,-3,\ldots. Thus (−1)!(-1)!, (−2)!(-2)!, and so on are undefined, while negative nonintegers such as (−1/2)!(-1/2)! can have finite values.

The value 0!0! is not a problem: it is

0!=Γ(1)=1.0!=\Gamma(1)=1.

Why use the Gamma function?

Many functions can be made to agree with the integer factorial values, so merely requiring a function to satisfy f(n)=n!f(n)=n! at integers does not uniquely determine an extension. The Gamma function is the conventional choice because it is smooth, satisfies the factorial recurrence, has the integral representation above, and is log-convex on the positive real numbers.

This convention is used in probability, statistics, calculus, and combinatorics. For example, continuous extensions of binomial coefficients use

(xk)=Γ(x+1)Γ(k+1)Γ(x−k+1),\binom{x}{k}=\frac{\Gamma(x+1)}{\Gamma(k+1)\Gamma(x-k+1)},

whenever the Gamma terms are defined.

Common mistakes

  • Writing x!=x⋅(x−1)⋯1x!=x\cdot(x-1)\cdots1 for a noninteger. This finite product only naturally terminates when xx is a nonnegative integer. Use Γ(x+1)\Gamma(x+1) instead.
  • Using Γ(x)\Gamma(x) instead of Γ(x+1)\Gamma(x+1). The Gamma function shifts the factorial by one: n!=Γ(n+1)n!=\Gamma(n+1), not Γ(n)\Gamma(n).
  • Assuming all negative inputs are allowed. Negative nonintegers may be valid, but negative integers are poles and have no finite factorial value.
  • Expecting an elementary closed form for every decimal. Values such as 2.3!2.3! generally require numerical evaluation of the Gamma function.

References

  1. NIST Digital Library of Mathematical Functions, Chapter 5: Gamma Function
  2. Abramowitz and Stegun, Handbook of Mathematical Functions, Chapter 6: Gamma and Related Functions

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.