Factorial Calculator (n!)

Compute exact factorials, scientific notation, digit counts, and see step-by-step expansions. Ideal for math, statistics, and computer science problems.

Factorial Calculator

Exact value shown up to 500!. For larger n, you get scientific notation and digit count.

Mode

Result

5! = 120

Step-by-step expansion

5! = 5 × 4 × 3 × 2 × 1 = 120

Related values

What is a factorial?

The factorial of a non-negative integer n, written as n!, is the product of all positive integers from 1 up to n:

Definition:

\[ n! = 1 \cdot 2 \cdot 3 \cdots (n-1) \cdot n \quad \text{for } n \ge 1 \]

By convention, \[ 0! = 1 \]

Examples:

  • 1! = 1
  • 3! = 3 × 2 × 1 = 6
  • 5! = 5 × 4 × 3 × 2 × 1 = 120
  • 10! = 3,628,800

How this factorial calculator works

This tool is designed to be both practical and educational:

  • Exact factorials up to 500! using high-precision integer arithmetic.
  • Scientific notation & digit count for very large n up to 10,000.
  • Step-by-step expansion for small n so you can see the full product.
  • Permutations (nPr) and combinations (nCr) built directly from n!.

Algorithm and limits

For n ≤ 500, the calculator multiplies integers from 1 to n using JavaScript BigInt, so the result is exact and shown in full.

For 500 < n ≤ 10,000, the exact integer would have thousands of digits, so we compute:

  • The natural logarithm of n! using a running sum of logs.
  • The number of digits using \(\lfloor \log_{10}(n!) \rfloor + 1\).
  • A scientific notation approximation using the leading digits.

For even larger n, Stirling’s approximation \[ n! \approx \sqrt{2\pi n}\left(\frac{n}{e}\right)^n \] can be used; this is what the calculator falls back to if needed.

Factorials in permutations and combinations

Factorials appear naturally in counting problems:

Permutations (order matters)

The number of ways to arrange r objects chosen from n distinct objects is:

\[ {}_nP_r = \frac{n!}{(n-r)!} \]

Example: How many ways to arrange 3 letters chosen from A, B, C, D, E?

\[ {}_5P_3 = \frac{5!}{(5-3)!} = \frac{5!}{2!} = \frac{120}{2} = 60 \]

Combinations (order does not matter)

The number of ways to choose r objects from n distinct objects when order does not matter is:

\[ {}_nC_r = \binom{n}{r} = \frac{n!}{r!(n-r)!} \]

Example: How many 3-person committees can be formed from 5 people?

\[ {}_5C_3 = \frac{5!}{3!2!} = \frac{120}{6 \cdot 2} = \frac{120}{12} = 10 \]

Why does factorial grow so fast?

Each time you increase n by 1, you multiply the previous factorial by n+1: \[ (n+1)! = (n+1)\cdot n! \] This repeated multiplication makes factorials grow faster than polynomials and even many exponentials.

For example:

  • 10! = 3,628,800
  • 20! ≈ 2.43 × 1018
  • 50! ≈ 3.04 × 1064

Because of this rapid growth, computers must use special big-integer arithmetic and approximations for large n.

Common factorial values table

n n!
0 1
1 1
2 2
3 6
4 24
5 120
6 720
7 5,040
8 40,320
9 362,880
10 3,628,800
15 1,307,674,368,000
20 2,432,902,008,176,640,000

FAQ

What is 0! and why is it 1?

Defining 0! = 1 keeps combinatorics formulas consistent. For example, the number of ways to choose 0 items from n is: \[ \binom{n}{0} = \frac{n!}{0!\,n!} = 1 \] This only works if 0! = 1.

Can I compute factorials of non-integers?

The standard factorial is only defined for non-negative integers. The Gamma function Γ(x) extends the idea of factorial to non-integer values, with Γ(n+1) = n! for positive integers n. This calculator focuses on integer factorials.

Where are factorials used?

  • Combinatorics: permutations, combinations, binomial coefficients.
  • Probability: distributions like binomial and Poisson.
  • Series expansions: Taylor and Maclaurin series.
  • Computer science: algorithm analysis, counting problems.