Skip to content

Factorial Calculator (n!, n!! and Gamma)

Exact n! up to 1000!, double factorials n!! and the gamma function Γ(x) for non-integers.

Your details

Calculate

A whole number from 0 to 1000.

Results update as you type

Result

3,628,800

Scientific notation
3.6288 × 10⁶
Number of digits
7
Trailing zeros
2

Step-by-step solution
  1. Multiply every whole number from n down to 1: 10! = 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 3,628,800
  2. Trailing zeros (Legendre’s formula): ⌊10/5⌋ = 2
  3. Stirling’s approximation for comparison: √(2π·10) · (10/e)¹⁰ ≈ 3,598,700

The factorial of a whole number nn, written n!n!, is the product of all positive integers up to nn: 5!=5×4×3×2×1=1205! = 5 \times 4 \times 3 \times 2 \times 1 = 120. It counts the number of ways to arrange nn distinct objects in a row, which is why it sits at the heart of permutations, combinations, probability and series such as ex=∑xn/n!e^x = \sum x^n / n!.

Factorials grow astonishingly fast. 10!=3,628,80010! = 3,628,800, 20!20! already has 19 digits and 100!100! has 158. Ordinary calculators give up at 170!170!, the largest factorial a double-precision number can hold. This calculator uses exact integer arithmetic instead, so it returns every digit of n!n! for any nn up to 1000 (that is 2,568 digits), together with the digit count, the number of trailing zeros and the value in scientific notation.

Two related tools are built in: the double factorial n!!n!!, which multiplies every other number, and the gamma function Γ(x)\Gamma(x), which extends the factorial to fractions and negative non-integers, so you can evaluate expressions like "12!\tfrac{1}{2}!".

How to use this calculator

  1. Pick n! for an ordinary factorial, n!! for a double factorial or Γ(x) for the gamma function.
  2. Enter nn (a whole number) or xx (any real number except 0 and negative integers in the gamma mode).
  3. Read the result: in full when it has up to 30 digits, otherwise in scientific notation, with all the digits listed in the table below it.
  4. Check the extra figures (number of digits, trailing zeros, ln⁡Γ\ln \Gamma) and open the steps for the product, Legendre’s formula and Stirling’s approximation.

The formula

Factorial. For a non-negative integer nn,

n!=∏k=1nk=n×(n−1)×⋯×2×1,0!=1,n!=n×(n−1)!n! = \prod_{k=1}^{n} k = n \times (n-1) \times \cdots \times 2 \times 1, \qquad 0! = 1, \qquad n! = n \times (n-1)!

Double factorial. n!!=n(n−2)(n−4)⋯n!! = n(n-2)(n-4)\cdots, stopping at 1 for odd nn and at 2 for even nn, with 0!!=(−1)!!=10!! = (-1)!! = 1.

Gamma function. Euler’s integral Γ(x)=∫0∞tx−1e−t dt\Gamma(x) = \int_0^\infty t^{x-1} e^{-t}\,dt satisfies Γ(n+1)=n!\Gamma(n+1) = n! and Γ(x+1)=x Γ(x)\Gamma(x+1) = x\,\Gamma(x). For negative non-integers the reflection formula Γ(x) Γ(1−x)=π/sin⁡(πx)\Gamma(x)\,\Gamma(1-x) = \pi / \sin(\pi x) applies; Γ\Gamma has poles at 0,−1,−2,…0, -1, -2, \ldots

Trailing zeros (Legendre’s formula): the number of zeros at the end of n!n! is ⌊n/5⌋+⌊n/25⌋+⌊n/125⌋+⋯\lfloor n/5 \rfloor + \lfloor n/25 \rfloor + \lfloor n/125 \rfloor + \cdots

Stirling’s approximation estimates large factorials: n!≈2πn (n/e)nn! \approx \sqrt{2\pi n}\,(n/e)^n, with a relative error close to 1/(12n)1/(12n).

Worked example

  • 5!=5×4×3×2×1=1205! = 5 \times 4 \times 3 \times 2 \times 1 = 120
  • 10!=3,628,80010! = 3{,}628{,}800, and 20!=2,432,902,008,176,640,00020! = 2{,}432{,}902{,}008{,}176{,}640{,}000
  • 100!100! has 158 digits and ends with ⌊100/5⌋+⌊100/25⌋=20+4=24\lfloor 100/5 \rfloor + \lfloor 100/25 \rfloor = 20 + 4 = 24 zeros; it is about 9.332621544×101579.332621544 \times 10^{157}
  • 9!!=9×7×5×3×1=9459!! = 9 \times 7 \times 5 \times 3 \times 1 = 945 and 10!!=10×8×6×4×2=3,84010!! = 10 \times 8 \times 6 \times 4 \times 2 = 3{,}840
  • Γ(0.5)=π≈1.772453851\Gamma(0.5) = \sqrt{\pi} \approx 1.772453851, Γ(4.5)≈11.6317284\Gamma(4.5) \approx 11.6317284 and Γ(−0.5)=−2π≈−3.544907702\Gamma(-0.5) = -2\sqrt{\pi} \approx -3.544907702

Where factorials appear

  • Arrangements: 8 runners can finish a race in 8!=40 3208! = 40\,320 different orders.
  • Combinations: the number of ways to choose kk items from nn is (nk)=n!k! (n−k)!\binom{n}{k} = \frac{n!}{k!\,(n-k)!}; a 6-from-49 lottery has 49!6! 43!=13 983 816\frac{49!}{6!\,43!} = 13\,983\,816 possible draws.
  • Probability: the chance that a shuffled deck of 52 cards is in one specific order is 1/52!1/52!, about 1.24×10−681.24 \times 10^{-68}.
  • Series: e=∑n≥01/n!e = \sum_{n \ge 0} 1/n! and sin⁡x=x−x3/3!+x5/5!−⋯\sin x = x - x^3/3! + x^5/5! - \cdots
  • Statistics: the Poisson and binomial distributions, and through the gamma function, the chi-square, Student and gamma distributions.

For very large factorials in formulas, work with logarithms: ln⁡(n!)=ln⁡Γ(n+1)\ln(n!) = \ln\Gamma(n+1), which the gamma mode gives directly.

Why 0! equals 1

There is exactly one way to arrange an empty set: do nothing. The rule n!=n×(n−1)!n! = n \times (n-1)! also forces it, since 1!=1×0!1! = 1 \times 0! requires 0!=10! = 1. And the gamma function agrees: Γ(1)=∫0∞e−t dt=1\Gamma(1) = \int_0^\infty e^{-t}\,dt = 1. Without this convention, formulas such as (n0)=n!0! n!=1\binom{n}{0} = \frac{n!}{0!\,n!} = 1 would break.

Frequently asked questions

What is the largest factorial a normal calculator can show?

170! ≈ 7.257 × 10³⁰⁶ is the largest factorial that fits in a standard double-precision number; 171! ≈ 1.241 × 10³⁰⁹ overflows, which is why many calculators show an error. This calculator uses exact big-integer arithmetic and goes up to 1000!.

How many zeros are at the end of 100!?

Each trailing zero comes from a factor 10 = 2 × 5, and factors of 5 are the scarce ones. Count them with Legendre’s formula: ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24 zeros.

Can you take the factorial of a fraction or a negative number?

Not with the product definition, but the gamma function extends it: x! = Γ(x + 1). So (1/2)! = Γ(1.5) = √π / 2 ≈ 0.8862. Negative integers remain undefined, because Γ has poles at 0, −1, −2 and so on; other negative numbers do have a value, such as Γ(−0.5) ≈ −3.5449.

What is the difference between n!! and (n!)!?

n!! is the double factorial, the product of every other number: 9!! = 9 × 7 × 5 × 3 × 1 = 945. (n!)! is the factorial of a factorial, a vastly larger number: (3!)! = 6! = 720.

How accurate is the gamma function here?

For positive integers the result is exact, since Γ(n) = (n − 1)!. Elsewhere the calculator uses the Lanczos approximation published in Numerical Recipes, whose relative error is below 10⁻¹⁵; results are shown to 10 significant digits.

Sources

Last updated:

More Math calculators

People also use