Skip to content

Factorial Calculator — Step-by-Step Solutions

The Factorial Calculator computes factorials (n!), double factorials (n!!), displays factorial tables, and evaluates the Gamma function for non-integer values. It uses BigInt for exact results up to 170!.

Enter a number to see its factorial with step-by-step expansion showing the full multiplication chain. The table mode displays factorials from 0! to 20! with digit counts.

Factorial
—

Your calculations will appear here

How to Use the Factorial Calculator

  1. Choose a mode: n! Factorial, n!! Double Factorial, Factorial Table (0-20), or Gamma Function for non-integer inputs.
  2. Enter a non-negative whole number in the box (for the Gamma mode you can enter a decimal such as 4.5). The result appears as you type.
  3. For ordinary factorials the answer is exact, with every digit shown, even when it has hundreds of digits. For n up to 20 the expansion n x (n - 1) x ... x 1 is written out too.
  4. Use the table mode to look up factorials from 0! to 20! together with their digit counts, which is handy for permutation and combination problems.

Formula and Theory

The factorial of a non-negative integer n, written n!, is the product of all positive integers up to n: n! = n x (n - 1) x ... x 2 x 1. By convention 0! = 1, which keeps formulas such as the number of ways to arrange zero objects (exactly one way) consistent.

Factorials count arrangements. There are n! ways to order n different objects, and they sit inside the formulas for permutations, nPr = n! / (n - r)!, and combinations, nCr = n! / (r! (n - r)!). They also appear in the Taylor series of e^x, sin x and cos x and in the Poisson and binomial distributions.

Factorials grow extremely fast: 10! is already 3,628,800, 20! is about 2.4 x 10^18, and 21! no longer fits in a standard 64-bit integer, which is why this calculator uses arbitrary-precision integers. The Stirling approximation, n! is roughly sqrt(2 pi n) (n/e)^n, is useful for estimating large factorials.

The double factorial n!! multiplies every second number: n x (n - 2) x (n - 4) x ... down to 2 or 1. It is not the same as (n!)!. The Gamma function extends the factorial to non-integers through n! = Gamma(n + 1), with (1/2)! = sqrt(pi) / 2.

Worked Examples

Example 1: A small factorial

Problem: Calculate 5!.

Solution: 5! = 5 x 4 x 3 x 2 x 1. Multiply step by step: 5 x 4 = 20, 20 x 3 = 60, 60 x 2 = 120, 120 x 1 = 120.

Answer: 120

Example 2: Using factorials for a combination

Problem: How many ways can you choose 3 people from 10? That is 10C3 = 10! / (3! x 7!).

Solution: 10! = 3,628,800. 3! = 6 and 7! = 5,040, so the denominator is 6 x 5,040 = 30,240. 3,628,800 / 30,240 = 120. (Cancelling 7! first gives the same: 10 x 9 x 8 / 6 = 720 / 6 = 120.)

Answer: 120 ways

Example 3: Double factorial

Problem: Calculate 8!! and 7!!.

Solution: 8!! = 8 x 6 x 4 x 2 = 384. 7!! = 7 x 5 x 3 x 1 = 105.

Answer: 8!! = 384 and 7!! = 105

Example 4: Gamma function for a non-integer

Problem: What is 4.5! (that is, Gamma(5.5))?

Solution: Use Gamma(n + 1) = n x Gamma(n) repeatedly: Gamma(5.5) = 4.5 x 3.5 x 2.5 x 1.5 x 0.5 x Gamma(0.5), and Gamma(0.5) = sqrt(pi) = 1.7725. The product 4.5 x 3.5 x 2.5 x 1.5 x 0.5 = 29.53125, so Gamma(5.5) = 29.53125 x 1.77245 = 52.3428.

Answer: 52.3428 (approximately)

Frequently Asked Questions

Why is 0! equal to 1?
There is exactly one way to arrange zero objects: do nothing. Defining 0! = 1 also makes the formula n! = n x (n - 1)! work at n = 1 and keeps the combinations formula correct, for example nC0 = 1.
Can you take the factorial of a negative number?
Not for integers. Factorials of negative whole numbers are undefined. The Gamma function can be defined for most negative non-integers, but it has no value at 0, -1, -2 and so on.
What is the largest factorial this calculator can compute?
Ordinary factorials are computed exactly up to 1000!, which has over 2,500 digits. Double factorials go up to 300!!. For larger values, use the Stirling approximation.
How many digits does n! have?
It grows quickly: 20! has 19 digits, 52! (the number of ways to order a deck of cards) has 68 digits, and 170! has 307 digits. The factorial table mode lists digit counts for 0 to 20.
What is the difference between n!! and (n!)!?
The double factorial n!! multiplies every second integer from n down, so 7!! = 7 x 5 x 3 x 1 = 105. The factorial of a factorial, (n!)!, is a vastly larger number.
What is the factorial of a decimal?
It is defined through the Gamma function: x! = Gamma(x + 1). For example, 0.5! = sqrt(pi) / 2, about 0.8862. Use the Gamma Function mode for these.

Related General Calculators

Related Articles