Factorial Calculator (n!, Permutations nPr, Combinations nCr)

Precisely calculate the factorial n! of a non-negative integer n. Also supports permutations (nPr) and combinations (nCr), using BigInt for exact integer results with no digit limit. Includes a factorial reference table for 0-20.

Factorial reference table for 0-20

A table listing the values of 0! through 20!. Note that 20! already has 19 digits.

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
11 39,916,800
12 479,001,600
13 6,227,020,800
14 87,178,291,200
15 1,307,674,368,000
16 20,922,789,888,000
17 355,687,428,096,000
18 6,402,373,705,728,000
19 121,645,100,408,832,000
20 2,432,902,008,176,640,000

Factorials, permutations and combinations

The factorial n! is the product of every integer from one to n, and it counts **the number of ways to arrange n things in a row**. Five factorial is 120 and ten factorial is 3,628,800: the value explodes as soon as n grows a little. By twenty factorial the result already runs past eighteen digits, beyond what ordinary floating-point numbers can hold exactly.

This tool uses **BigInt to compute the exact integer with no limit on the number of digits**. Besides the factorial it handles permutations nPr, the number of ways to choose r things from n and arrange them, and combinations nCr, the number of ways to choose r things from n without regard to order. They relate as nPr = n! ÷ (n−r)! and nCr = n! ÷ (r! × (n−r)!), and **whether order matters is the only thing separating them.** A ready-reckoner of the factorials from zero to twenty is included.

How to calculate

  1. Choose the kind of calculation Pick the factorial, permutation or combination tab.
  2. Enter n A whole number from 0 to 10,000. The ceiling is there for the sake of computation time.
  3. Enter r, for permutations and combinations A whole number from 0 up to n.
  4. Read the result Even very long values are shown in full as exact integers, never abbreviated.

Tips for getting more out of it

  • Factorial (n!) is the product of every integer from 1 to n. For example, 5! = 5x4x3x2x1 = 120. By special definition, 0! = 1.
  • Permutation (nPr) counts the ways to choose r items from n distinct items and arrange them in order. Because order matters, the result is always at least as large as the corresponding combination. For example, 5P2 = 5x4 = 20.
  • Combination (nCr) counts the ways to choose r items from n distinct items without regard to order. For example, 5C2 = 10 (dividing 5P2 = 20 by the 2! = 2 ways to reorder the 2 chosen items).
  • Factorials grow extremely fast: 20! already has 19 digits, and 100! has 158 digits. This tool uses BigInt, so it computes exact values with no rounding error even for large n.
  • If n is too large (above 10,000), the tool returns an error due to computation cost — a practical limit to prevent the browser from becoming unresponsive.

Where this helps

Solving probability problems

Useful for checking your own working on counting problems involving draws or card hands.

Counting arrangements

Handy for practical enumeration too, such as seating plans or tournament pairings.

Finding binomial coefficients

nCr is precisely the coefficient in the binomial theorem, so you can read values off Pascal's triangle directly.

Checking your own code

Compare against the exact value to confirm that a factorial function you wrote has not overflowed at large n.

Factorial terms explained

Factorial (n!)
The product of the integers from one to n. **Zero factorial is defined as one**, following the convention that an empty product equals one.
Permutation (nPr)
The number of ways to choose r things from n and **arrange** them, given by n! ÷ (n−r)!.
Combination (nCr)
The number of ways to **choose** r things from n, disregarding order, given by n! ÷ (r! × (n−r)!).
Binomial coefficient
The coefficient of each term when (a+b)^n is expanded; it equals nCr.
BigInt
The JavaScript type for integers of unlimited size. **The ordinary number type loses exactness beyond 2^53.**
Stirling's approximation
A formula approximating n! for large n, used where an exact value is not needed.

Frequently Asked Questions

0! = 1 is defined by mathematical convention. It's natural if you think of it as "there is exactly one way to arrange an empty set" (the one way of arranging nothing). It's also the definition required for the recursive property n! = n x (n-1)! to hold even at n=1.

A permutation (nPr) counts the ways to "choose and arrange" items, so order matters (AB and BA are different). A combination (nCr) counts the ways to "just choose" items, so order does not matter (AB and BA are the same). This means nCr is always less than or equal to nPr, with the relationship nCr = nPr / r!.

It supports integers up to 10,000. 10,000! is a massive number with over 35,000 digits, and going beyond that could make the browser sluggish due to display and computation cost, so a practical limit is enforced.

Beyond permutation and combination calculations, factorials play a foundational role across many areas of mathematics, including probability theory (dice and card combinations), statistics (formulas for the binomial and Poisson distributions), and Taylor series expansions (factorials appear in the series expansion of functions like e^x).
Tool-kun

Side Note — Why is the factorial symbol an exclamation mark?

The "!" symbol for factorial is generally credited to the French mathematician Christian Kramp, who introduced it in a book published in 1808. Before that, mathematicians used a variety of ad hoc notations with no agreed-upon standard. Various explanations exist for Kramp's choice, but a popular one is that it captures the sense of "astonishment" at how quickly factorial values explode in size.

This explosive growth is also captured by Stirling's approximation (n! ~ sqrt(2*pi*n) * (n/e)^n), which is widely used for approximate calculations across statistics, probability theory, and combinatorics. For values of n too large to compute n! exactly, this approximation plays a genuinely practical role.

The ideas behind permutations and combinations underlie everyday probability problems, from calculating lottery odds to counting the number of ways to shuffle a deck of cards (a standard 52-card deck has 52! possible orderings, roughly 8x10^67). The combination count nCr also appears as the entries of Pascal's Triangle and is closely tied to the binomial theorem (the expansion of (a+b)^n).