Calculator Tools

Permutations vs combinations: when order matters, and why a combination lock is misnamed

Counting arrangements and selections sounds like school maths, but it decides lottery odds, password strength and how many handshakes happen in a room. This guide builds both formulas from scratch and shows the numbers in pictures.

By the Toolcloak team8 October 20264 min read
In this article
  1. Factorials: the building block
  2. Permutations: order matters
  3. Combinations: order does not matter
  4. Four kinds of counting
  5. Locks, lotteries and handshakes
  6. Quick practice

How many ways can five people sit in a row? How many different teams of three can be chosen from the same five? The numbers are 120 and 10. They sound like the same problem, but one of them cares about order and the other does not. That one question, “does order matter?”, is the whole difference between permutations and combinations.

Factorials: the building block

The factorial of n, written n!, is n × (n−1) × (n−2) × … × 1. It counts how many ways n different things can be lined up. With three letters A, B, C there are 3 × 2 × 1 = 6 lineups, because you have 3 choices for the first spot, 2 left for the second and 1 for the last.

How fast n! grows
11!22!63!244!1205!7206!5,0407!

1, 2, 6, 24, 120, 720, 5,040. By 10! the number is already 3,628,800 and by 20! it passes two quintillion.

Factorials get big very fast
3,628,80010!Ways to order ten items
1.6 × 10²⁵25!About 15 trillion trillion orderings
8 × 10⁶⁷52!Orderings of a shuffled deck: almost certainly never repeated

Any properly shuffled deck of cards is very likely to be in an order that has never existed before in history.

Enter n and r and get nPr and nCr, including the factorial steps.Open Permutation & Combination Calculator

Permutations: order matters

Imagine a race with 5 runners where gold, silver and bronze go to different people. The first medal can go to 5 runners, the second to the 4 left and the third to the remaining 3: 5 × 4 × 3 = 60 ways. That is 5P3.

Awarding 3 medals among 5 runners
  1. 1Gold: 5 choicesAny of the five runners can win.
  2. 2Silver: 4 choicesThe gold winner is out, four are left.
  3. 3Bronze: 3 choices5 × 4 × 3 = 60 different podiums.

Combinations: order does not matter

Now pick a team of 3 from 5 people. The team {Asha, Ben, Chitra} is the same team no matter who was picked first. Each team appears in 3! = 6 different orders inside the 60 podium-style lists, so we divide by 6: 60 ÷ 6 = 10 teams.

Same five people, three places
Permutations (5P3)60
  • Gold, silver, bronze are different roles
  • ABC and CBA count as different
  • Use when order or position matters
Combinations (5C3)10
  • Just a team of three, no roles
  • ABC and CBA are the same team
  • Use when you only choose a group

Every team of three can be arranged in 3! = 6 ways, so 60 ÷ 6 = 10.

The formula is nCr = n! ÷ (r! × (n − r)!). A useful symmetry: choosing r items to take is the same as choosing n − r items to leave behind, so nCr = nC(n−r). That is why 5C3 = 5C2 = 10.

Ways to choose k people from 20 (20Ck)
1019024,845438,76061,25,97081,84,756101,25,9701238,760144,8451619018120

The counts rise to a peak at k = 10 (1,84,756) and fall symmetrically. The same shape appears in Pascal’s triangle and in the bell curve.

SituationOrder matters?FormulaExample answer
Podium of 3 from 5 runnersYes5P360
Team of 3 from 5 peopleNo5C310
4-digit PIN, digits can repeatYes10⁴10,000
4-digit code, no repeated digitYes10P45,040
5-card poker hand from 52No52C525,98,960
Lottery, 6 numbers from 49No49C61,39,83,816

Four quick questions to ask: does order matter, can items repeat, how many are available, and how many are chosen.

Four kinds of counting

Which counting rule to use
Order matters, no repeatsnPr = n! ÷ (n − r)!. Podiums, seating, racing positions.
Order matters, repeats allowednʳ. PINs, plates, passwords made from a small set of characters.
Order does not matter, no repeatsnCr = n! ÷ (r! (n − r)!). Teams, lotteries, card hands.
Order does not matter, repeats allowed(n + r − 1)Cr. Choosing 3 scoops from 5 flavours when flavours can repeat.

Most real problems fall into the first three. The last is rarer but useful for “with replacement” selections.

Locks, lotteries and handshakes

A “combination lock” asks for an ordered code, so it is a permutation lock. With four wheels of ten digits and repeats allowed, there are 10 × 10 × 10 × 10 = 10,000 codes. A lottery really is a combination: only the set of numbers counts, not the order in which the balls come out.

Choosing 6 numbers from 49
1,39,83,816Possible tickets49C6, order does not matter
1 in 14 millionYour chance with one ticketAbout 0.000007%
720Orders of the same six balls6! orderings that all count as one ticket

If order mattered, there would be 49P6 = 10,068,347,520 tickets, which is 720 times more.

Handshakes are combinations, because a handshake between A and B is the same handshake as between B and A. For n people the number of handshakes is nC2 = n × (n − 1) ÷ 2, which grows much faster than the head count.

Handshakes if everyone shakes hands once
5 people
10
10 people
45
20 people
190
50 people
1,225
100 people
4,950

Doubling the people from 50 to 100 does not double the handshakes. It multiplies them by about four, from 1,225 to 4,950.

Quick practice

  1. How many ways can 4 books be lined on a shelf? 4! = 24.
  2. How many 2-person committees from 6 people? 6C2 = 15, so 15.
  3. How many 3-letter codes from A–Z with no repeated letter? 26P3 = 15,600.
  4. How many ways to pick 4 from 4? 4C4 = 1, because there is only one group.

Once you can tell whether order matters, the formula follows. Try several n and r values in the calculator and watch how quickly the numbers grow.

Questions people ask

What is the difference between a permutation and a combination?

In a permutation order matters (ABC differs from CBA). In a combination it does not (ABC and CBA are the same group).

What is the nCr formula?

nCr = n! ÷ (r! × (n − r)!), the number of ways to choose r items from n when order does not matter.

What is 0! equal to?

1. There is exactly one way to arrange nothing, and defining 0! = 1 keeps the formulas working.

How many combinations in a 6/49 lottery?

1,39,83,816, which is 49C6. A single ticket has a 1 in 1,39,83,816 chance.

Is a combination lock a permutation or a combination?

A permutation. The order of the digits matters, so 1-2-3 and 3-2-1 are different codes.

How many ways can a deck of 52 cards be shuffled?

52!, about 8 × 10⁶⁷. That is so large that a thoroughly shuffled deck has almost certainly never occurred before.