Combination Calculator

Enter n (total number of items) and r (items to select) to calculate C(n,r) — the number of unique combinations possible when order doesn't matter. You also get the corresponding permutation count (nPr) and key factorials as supporting results.

The total size of the set you are choosing from.

How many items you want to choose from the set. Must be ≤ n.

Results

Combinations C(n,r)

--

Permutations P(n,r)

--

n! (n Factorial)

--

r! (r Factorial)

--

(n−r)! Factorial

--

Combinations vs Permutations

Frequently Asked Questions

What is a combination?

A combination is a selection of r items from a set of n distinct items where the order of selection does not matter. For example, choosing 2 fruits from {apple, banana, cherry} gives the same combination regardless of which fruit you pick first. This differs from permutations, where the order does matter.

What is the combination formula (nCr)?

The formula is C(n, r) = n! / (r! × (n − r)!), where n is the total number of items, r is the number chosen, and '!' denotes factorial. For example, C(5, 2) = 5! / (2! × 3!) = 10, meaning there are 10 ways to choose 2 items from 5.

What is the difference between a permutation and a combination?

In a combination, the order of selected items does not matter (e.g., {A, B} = {B, A}). In a permutation, order does matter (AB ≠ BA). Permutations always produce a larger or equal count than combinations for the same n and r.

How do I calculate permutations from combinations?

Multiply the combination result by r! (r factorial). So P(n, r) = C(n, r) × r!. For example, if C(5, 2) = 10 and r! = 2! = 2, then P(5, 2) = 20.

How do I calculate combinations from permutations?

Divide the permutation count by r!. So C(n, r) = P(n, r) / r!. This accounts for all the different orderings of the same subset that permutations count separately but combinations treat as identical.

Can n be less than r in a combination?

No. You cannot choose more items than exist in the set. If r > n, the combination is mathematically undefined (or considered 0). This calculator will flag that case and return 0.

What is the handshake problem?

The handshake problem asks: if n people are in a room and each person shakes hands with every other person exactly once, how many handshakes occur? The answer is C(n, 2) = n(n − 1) / 2. For 10 people, that's C(10, 2) = 45 handshakes.

Why does this calculator have a maximum of 170 for n?

JavaScript's floating-point numbers cannot accurately represent factorials beyond 170! (which already exceeds 10^306, near the limit of a 64-bit float). Inputs above 170 would produce Infinity or incorrect results, so the calculator caps n and r at 170 for reliable output.

More Math Tools