Find a course

Module 4: CountingLesson 9 of 1215 min

Permutations, Combinations and the Binomial Theorem

Count ordered arrangements and unordered selections, handle repetition with stars and bars, and expand powers with the binomial theorem and Pascal's triangle.

Step 1 of 13Learn

Permutations: order matters

Eight runners race. How many ways can the gold, silver and bronze medals be awarded? Gold can go to any of 8 runners, silver to any of the remaining 7, bronze to any of the remaining 6: 8·7·6 = 336 ways.

That's a permutation: an ordered arrangement of distinct items. The number of ways to arrange k items chosen from n is

P(n, k) = n·(n − 1)·⋯·(n − k + 1) = n!/(n − k)!

where n! ("n factorial") is n·(n − 1)·⋯·2·1, and 0! = 1 by definition.

Arranging all n items gives P(n, n) = n!. The letters of the word MATH can be arranged in 4! = 24 ways. A deck of 52 cards can be shuffled into 52! ≈ 8 × 10⁶⁷ orders, so many that any well-shuffled deck is almost certainly in an order never seen before in history.

Factorials grow faster than exponentials: 10! = 3,628,800 and 20! ≈ 2.4 × 10¹⁸. That's why the traveling salesman problem, which checks every order of visiting n cities, becomes impossible by brute force beyond about 15 or 20 cities.

Arrangements with repeated letters. The letters of LEVEL can't all be told apart: swapping the two L's or the two E's gives the same word. Divide out those swaps: 5!/(2!·2!) = 120/4 = 30 distinct arrangements. In general, for n items with groups of identical items of sizes n₁, n₂, …, the count is n!/(n₁!·n₂!·⋯).

Step 2 of 13Practice · Work it out

In how many ways can a president, vice president and treasurer be chosen from a club of 12 members, if no one holds two offices?

Step 3 of 13Learn

Combinations: order does not matter

Now choose a 3-person committee from the same 12 members, with no titles. Choosing Ana, Ben and Cal is the same committee as Cal, Ana and Ben. Each committee was counted 3! = 6 times among the 1,320 ordered choices, once for each order. So the number of committees is 1,320/6 = 220.

That's a combination: an unordered selection. The number of ways to choose k items from n is

C(n, k) = n!/(k!(n − k)!)

also written as "n choose k." It's the permutation count divided by k!, the number of orderings of the chosen items.

Examples:

  • A 5-card poker hand from 52 cards: C(52, 5) = 2,598,960 hands.
  • A lottery choosing 6 numbers from 49: C(49, 6) = 13,983,816. One ticket has about a 1 in 14 million chance.
  • Bit strings of length 10 with exactly 3 ones: choose which 3 positions hold ones, C(10, 3) = 120.

Symmetry: C(n, k) = C(n, n − k). Choosing 3 people to be on a committee is the same as choosing the 9 who are off it.

Deciding which to use. Ask: if I rearrange my selection, do I get a different outcome? If yes (rankings, passwords, seating, offices), use permutations. If no (committees, hands of cards, sets of toppings), use combinations. Many problems mix both: choose a 4-person team from 10 people (C(10, 4) = 210) and then pick a captain from the team (4 ways), for 840 total.

Step 4 of 13Compare

Permutation or combination?

AspectPermutation P(n, k)Combination C(n, k)
OrderMattersDoesn't matter
Formulan! / (n − k)!n! / (k!(n − k)!)
3 from 12 club members1,320 (president, VP, treasurer)220 (a committee)
Key wordArrange, rank, assign rolesChoose, select, a group

Step 5 of 13Practice · Sort into groups

Does each count call for a permutation or a combination?

Tap an item, then tap its group (or drag it there).

Step 6 of 13Practice · Work it out

How many 5-card hands from a standard 52-card deck contain exactly 2 aces?

Step 7 of 13Learn

Repetition and stars and bars

So far, items couldn't be reused. When they can:

  • Ordered, with repetition: nᵏ. A 4-digit PIN: 10⁴.
  • Unordered, with repetition: C(n + k − 1, k). This is the stars and bars formula.

Example. A bakery sells 4 kinds of donuts. How many ways can you buy a dozen? Order doesn't matter and kinds can repeat. Picture the 12 donuts as stars and use 3 bars to separate them into 4 kinds:

●●● | ●●●●● | | ●●●●

means 3 of kind 1, 5 of kind 2, none of kind 3 and 4 of kind 4. Every arrangement of 12 stars and 3 bars in a row gives one purchase, and vice versa. That's a bijection, so count the arrangements: choose which 3 of the 15 positions hold bars, C(15, 3) = 455.

The same idea counts nonnegative integer solutions of x₁ + x₂ + x₃ + x₄ = 12: also 455.

Order mattersOrder doesn't matter
No repetitionP(n, k) = n!/(n − k)!C(n, k) = n!/(k!(n − k)!)
Repetition allowednᵏC(n + k − 1, k)

That table covers most counting problems you'll meet. The skill is translating a word problem into "n things, choose k, does order matter, can things repeat?" and then reading off the formula.

Step 8 of 13Practice · Diagram

Four ways to choose k from n

Tap the formula for counting 4-digit PINs.

Tap the shape that answers the question, then press Check.

Four ways to choose k from nTwo-by-two matrix: C(n + k − 1, k), n^k, C(n, k), P(n, k).C(n + k − 1, k)n^kC(n, k)P(n, k)OrderDoesn't matterMattersRepetitionNot allowedAllowed
C(n + k − 1, k)

Stars and bars: scoops of ice cream, identical candies.

n^k

PINs, passwords, strings.

C(n, k)

Committees, poker hands.

P(n, k)

Medals, officer roles, rankings.

Step 9 of 13Practice · Match the pairs

Match each problem with its count.

Tap an answer, then tap the place where it belongs (or drag it there).

  1. Arrangements of the letters of BANANA
  2. Ways to choose 2 of 6 friends to invite
  3. Ways to award 1st and 2nd place among 6 runners
  4. Ways to choose 2 scoops from 3 flavors, repeats allowed

Step 10 of 13Learn

The binomial theorem and Pascal's triangle

Expand (x + y)³ = (x + y)(x + y)(x + y). Each term of the product picks x or y from each of the three factors. The term x²y appears once for each way to choose which one factor contributes the y: C(3, 1) = 3 ways. So

(x + y)³ = x³ + 3x²y + 3xy² + y³.

In general, the binomial theorem says

(x + y)ⁿ = Σ C(n, k) xⁿ⁻ᵏ yᵏ, summed over k = 0, 1, …, n.

That's why C(n, k) is called a binomial coefficient. Example: the coefficient of x²y⁵ in (x + y)⁷ is C(7, 5) = 21.

The coefficients form Pascal's triangle, where each entry is the sum of the two above it:

  • Row 0: 1
  • Row 1: 1 1
  • Row 2: 1 2 1
  • Row 3: 1 3 3 1
  • Row 4: 1 4 6 4 1
  • Row 5: 1 5 10 10 5 1

The rule behind it is Pascal's identity: C(n, k) = C(n − 1, k − 1) + C(n − 1, k). Its proof is a counting story: to choose k people from n, either include a particular person Pat (then choose k − 1 from the rest) or exclude Pat (choose k from the rest).

Setting x = y = 1 in the theorem gives C(n, 0) + C(n, 1) + ⋯ + C(n, n) = 2ⁿ: the number of subsets of each size adds up to the total number of subsets, matching the power set count from Module 3.

Step 11 of 13Practice · Diagram

Pascal's triangle (rows 0 to 5)

Each entry is the sum of the two above it. Row n lists C(n, 0), …, C(n, n): the coefficients of (x + y)n.

Tap the row whose coefficients expand (x + y)4.

Tap the shape that answers the question, then press Check.

Pascal's triangle (rows 0 to 5)Pyramid diagram: 1 5 10 10 5 1, 1 4 6 4 1, 1 3 3 1, 1 2 1, 1 1, 1.1 5 10 10 5 11 4 6 4 11 3 3 11 2 11 11
1 5 10 10 5 1

(x + y)5 = x5 + 5x4y + 10x3y2 + 10x2y3 + 5xy4 + y5.

1 4 6 4 1

C(4, 2) = 6.

1 3 3 1

(x + y)3 = x3 + 3x2y + 3xy2 + y3.

1 2 1
1 1
1

Step 12 of 13Practice · Work it out

What is the coefficient of x³y² in the expansion of (x + 2y)⁵?

Step 13 of 13Practice · Choose one

In how many ways can 10 identical candies be shared among 3 children, if a child may get none?