Factorial, Combination and Permutation Calculator

Calculate n!, combinations C(n,r) and permutations P(n,r) quickly.

Factorial, combination and permutation

These three operations form the basis of combinatorics. The factorial (n!) is the product of all positive integers up to n. The combination C(n,r) counts how many different groups of r elements can be formed from n, regardless of order. The permutation P(n,r) counts the same, but taking order into account.

Formulas

OperationFormula
Factorialn! = n × (n−1) × ... × 1
CombinationC(n,r) = n! / (r! × (n−r)!)
PermutationP(n,r) = n! / (n−r)!

Examples

5! = 120. C(5,2) = 5!/(2!×3!) = 10 (choose 2 of 5, order does not matter). P(5,2) = 5!/3! = 20 (choose and order 2 of 5).

When to use each

Use combination when order does not matter (e.g. choosing 3 people for a committee). Use permutation when order matters (e.g. deciding the podium of a race — 1st, 2nd and 3rd place).

Frequently asked questions

What's the difference between combination and permutation?

In a combination the order of chosen elements does not matter; in a permutation it does — so P(n,r) is always greater than or equal to C(n,r).

Why is n capped at 170?

Above that, the factorial exceeds the numeric precision a browser can represent accurately.

What is 0!?

By mathematical definition, 0! = 1.

Can r be greater than n?

No — you cannot choose more elements than exist in the original set.