Factorial Calculator

n!, double factorial, permutations nPr, combinations nCr and derangements, exact for big numbers, with digits and trailing zeros.

How it works

Pick what you need and type n (and r for permutations and combinations). All answers are exact, using big-integer maths, up to n = 3000.

n! multiplies 1 x 2 x ... x n. The double factorial n!! multiplies every second number down from n. nPr counts ordered selections, nCr counts unordered ones. A derangement !n counts ways to rearrange n items so that none stays in its place.

The formula

n! = n x (n-1) x ... x 1.   nCr = n! / (r! (n-r)!).   nPr = n! / (n-r)!

Worked example

5! = 120. 10 choose 3 = 120 and 10 pick 3 = 720 (nPr is nCr times 3! = 6). 4 derangements: !4 = 9. 100! has 158 digits and 24 trailing zeros.

Good to know

Common questions

Why is 0! equal to 1?
There is exactly one way to arrange nothing, and it keeps formulas like nCr working.
What is the largest n?
3000 for n!. For nPr and nCr, n up to 3000 with r up to n.
What is the difference between permutation and combination?
Order matters in a permutation (a race podium) and not in a combination (a team).
What is a derangement used for?
The "letters in wrong envelopes" problem. The chance approaches 1/e, about 36.8%.

More in Utilities.