Discrete MathematicsCounting: Choices, Arrangements and Selections2 of 7
Counting: Choices, Arrangements and Selections · 2

Permutations and Factorials

When we count choices across a row of slots where repetition is allowed, like a 4-digit PIN that can reuse any of the 10 digits in every spot (10×10×10×10=10410 \times 10 \times 10 \times 10 = \howmany{10^4}), the pool of options stays the same at every step. Now we want to count how many ways we can line up distinct items when we cannot repeat them.

1

Arranging All nn Items in a Line

We want to find the number of different orders for lining up a whole collection of distinct items, such as placing 3 different books on a shelf.

Permutations and Factorials
R\htmlClass{lc-pink}{\text{R}}
B\htmlClass{lc-blue}{\text{B}}
G\htmlClass{lc-green}{\text{G}}
ways= ?\text{ways} = \,?
Text solution
Fill the slots from left to right as the pool shrinksOnce you place a book in the first slot, it is no longer available for the remaining slots, so the number of choices drops by 1\operation{1} each step:
3⏟1st slot×2⏟2nd slot×1⏟3rd slot=6 ways\displaystyle \begin{aligned}\underbrace{3}_{\text{1st slot}} \times \underbrace{2}_{\text{2nd slot}} \times \underbrace{1}_{\text{3rd slot}} &= \howmany{6} \text{ ways}\end{aligned}

So there are 6\howmany{6} different orders to line up the 33 books.

For any positive whole number nn, the product of all whole numbers from nn down to 11 is written with an exclamation mark and read as "nn factorial":

n!⏟n factorial=n×(n−1)×(n−2)×⋯×10!=1(one way to leave an empty shelf)\displaystyle \begin{gathered} \begin{aligned} \underbrace{n!}_{n\text{ factorial}} &= n \times (n - 1) \times (n - 2) \\ &\quad \times \dots \times 1 \\[6pt] 0! &= \howmany{1} \end{aligned} \\ \text{(one way to leave an empty shelf)} \end{gathered}
2

Lining Up kk Items Out of nn

Now suppose we have more items than slots: we want to choose and order kk items out of nn distinct items, where the order of the lineup matters (a permutation).

1010
99
88
3 slots3\text{ slots}
7 books left\htmlClass{lc-orange}{7}\text{ books left}
7!, the cancelled tail\htmlClass{lc-orange}{7!}\text{, the cancelled tail}
Lining Up k Items Out of n
3 slots3\text{ slots}
10 books10\text{ books}
ways= ?\text{ways} = \,?
Text solution
Multiply down for only as many slots as you haveWith 1010 books and a shelf that only holds 33, the multiplication stops after the third slot because the other 7\leftover{7} books stay in the box:
10⏟1st slot×9⏟2nd slot×8⏟3rd slot=720 ways\displaystyle \begin{aligned}\underbrace{10}_{\text{1st slot}} \times \underbrace{9}_{\text{2nd slot}} \times \underbrace{8}_{\text{3rd slot}} &= \howmany{720} \text{ ways}\end{aligned}
Write the same product as a ratio of factorialsDividing the full 10!10! by the 7!\leftover{7!} ways to arrange the 7\leftover{7} unpicked books cancels the unused tail from 7\leftover{7} down to 1\leftover{1}:
10!(10−3)!=10!7!=10×9×8×7×6×5×4×3×2×17×6×5×4×3×2×1=720 ways\displaystyle \begin{aligned}&\frac{10!}{\leftover{(10 - 3)!}} \\ &= \frac{10!}{\leftover{7!}} \\ &= \frac{\begin{gathered}10 \times 9 \times 8 \times \\ \leftover{\cancel{7 \times 6 \times 5 \times 4 \times 3 \times 2 \times 1}}\end{gathered}}{\leftover{\cancel{7 \times 6 \times 5 \times 4 \times 3 \times 2 \times 1}}} \\ &= \howmany{720} \text{ ways}\end{aligned}

So there are 720\howmany{720} ways to line up 33 books out of 1010.

In factorial notation, the number of permutations of kk items chosen from nn distinct items is:

P(n,k)\displaystyle P(n, k) =n!(n−k)!⏟leftover items\displaystyle = \frac{n!}{\leftover{\underbrace{(n - k)!}_{\text{leftover items}}}}

With numbers, drawing kk slots and multiplying down kk steps is faster than writing out the fraction; save the factorial formula for algebra with variables.

In this lineup of 10 books, the slots on the shelf give the factors at the front of 10!10!, while the unpicked books in the box give the (10−k)!\leftover{(10 - k)!} tail that cancels out of 10!(10−k)!\frac{10!}{\leftover{(10 - k)!}}.

Stopping the multiplication after the slots on the shelf leaves the exact same factors as dividing the full factorial by the factorial of the leftover books in the box.
3

Algebra with Factorials

Sometimes we know the total count or have a fraction containing n!n! and need to simplify the expression or solve for nn. Because a factorial is a product counting down by 1\operation{1} at each step, we can pull factors off the front and leave the rest as a smaller factorial:

n!=n×(n−1)!=n×(n−1)×(n−2)!\displaystyle \begin{aligned}n! &= n \times (n - 1)! \\ &= n \times (n - 1) \times (n - 2)!\end{aligned}
Algebra with Factorials
(n+1)!(n−1)!\displaystyle \frac{(n+1)!}{(n-1)!} =  ?\displaystyle = \;?
P(n,2)=56n=  ?3×n!=360n=  ? \displaystyle \begin{alignedat}{2} P(n, 2) &= 56 &\qquad n &= \;? \\ 3 \times n! &= 360 & n &= \;? \end{alignedat}\,
Text solution
Expand the larger factorial until its tail matches the smaller factorialIn (n+1)!(n−1)!\frac{(n + 1)!}{\leftover{(n - 1)!}}, (n+1)(n + 1) is larger than (n−1)(n - 1), so pull factors off (n+1)!(n + 1)! one step at a time until (n−1)!\leftover{(n - 1)!} appears and cancels:
(n+1)!(n−1)!=(n+1)×n×(n−1)!(n−1)!=(n+1)n\displaystyle \begin{aligned} \frac{(n + 1)!}{\leftover{(n - 1)!}} &= \frac{(n + 1) \times n \times \leftover{\cancel{(n - 1)!}}}{\leftover{\cancel{(n - 1)!}}} \\ &= (n + 1)n \end{aligned}
Turn P(n,k)P(n, k) into slots to solve for nnFor P(n,2)=56P(n, 2) = 56, filling 22 slots starting from nn gives the product of two consecutive whole numbers:
n(n−1)=568×7=56  ⟹  n=8\displaystyle \begin{aligned} n(n - 1) &= 56 \\ 8 \times 7 &= 56 \implies n = 8 \end{aligned}
Isolate a single factorial before evaluatingFor 3×n!=360\operation{3} \times n! = 360, divide by 3\operation{3} first rather than expanding n!n!:
n!=1205!=120  ⟹  n=5\displaystyle \begin{aligned} n! &= 120 \\ 5! &= 120 \implies n = 5 \end{aligned}

Each factor pulled off the front of (n+1)!(n + 1)! steps the remaining factorial down by 1\operation{1}, and as soon as that tail reaches (n−1)!\leftover{(n - 1)!}, it cancels the denominator completely.

Unrolling the factorial on top from the front exposes the smaller factorial inside it, which cancels the one in the denominator.
4

Positional Restrictions: Picky Slots First

Now we want to count lineups when certain positions have rules about who or what is allowed in them.

Positional Restrictions: Picky Slots First
A\text{A}
B\text{B}
C\text{C}
D\text{D}
E\text{E}
friends\htmlClass{lc-mute}{\text{friends}}
A or B\htmlClass{lc-blue}{\text{A or B}}
ways= ?\text{ways} = \,?
Text solution
Fill the restricted slot before the unrestricted onesWhen 55 friends line up and only Alice or Bob can stand in the fifth slot on the far right, fill that picky fifth slot first (2\picky{2} choices), which leaves 44 people for the other 44 slots:
4×3×2×1×2⏟picked 1st=48 ways\displaystyle \begin{aligned}4 \times 3 \times 2 \times 1 \times \picky{\underbrace{2}_{\text{picked 1st}}} &= \howmany{48} \text{ ways}\end{aligned}
Watch for hidden restrictions like a leading zeroTo make a 4-digit number from the 66 tiles 0,1,2,3,4,50, 1, 2, 3, 4, 5 without repetition, the first slot cannot be 00 (5\picky{5} choices), and then 00 goes back into the pool of unused digits for the second slot (55 choices):
5⏟no 0×5⏟0 back in×4×3=300 four-digit numbers\displaystyle \begin{aligned}&\picky{\underbrace{5}_{\text{no } 0}} \times \underbrace{5}_{0\text{ back in}} \times 4 \times 3 \\ &= \howmany{300} \text{ four-digit numbers}\end{aligned}

If you fill the first four slots from left to right, the number of choices left for the fifth slot is 1\picky{1} or 0\leftover{0}, depending on whether you already placed one or both of Alice and Bob. Filling the fifth slot first keeps it at 2\picky{2} choices every time.

Fill the restricted slot first so your earlier choices don't change how many options it has left.
5

Keeping Items Together: The Glue Method

What if a restriction doesn't fix items to a specific spot, but requires a group of items to stay right next to each other anywhere in the line?

A\text{A}
B\text{B}
B\text{B}
A\text{A}
2!=2 orders inside\htmlClass{lc-blue}{2! = 2}\text{ orders inside}
A\text{A}
B\text{B}
C\text{C}
D\text{D}
E\text{E}
4 outside objects4\text{ outside objects}
Keeping Items Together: The Glue Method
A\text{A}
B\text{B}
C\text{C}
D\text{D}
E\text{E}
A and B next to each other\htmlClass{lc-blue}{\text{A and B}}\text{ next to each other}
ways= ?\text{ways} = \,?
Text solution
Glue the grouped items into one block and count the outside arrangementsWhen Alice and Bob must stand together among 55 friends, box them into [AB]\picky{[AB]} so you are arranging 44 outside objects ([AB],C,D,E\picky{[AB]}, C, D, E):
Outside arrangements\displaystyle \text{Outside arrangements} =4!\displaystyle = 4! =24\displaystyle = \howmany{24}
Multiply by the arrangements inside the boxFor every outside lineup, Alice and Bob can stand as [AB]\picky{[AB]} or [BA]\picky{[BA]} inside their box (2!\picky{2!} ways):
4!⏟outside×2!⏟inside=24×2=48 ways\displaystyle \begin{aligned}\underbrace{4!}_{\text{outside}} \times \picky{\underbrace{2!}_{\text{inside}}} &= \howmany{24} \times \picky{2} = \howmany{48} \text{ ways}\end{aligned}

Putting kk friends in a box turns them into a single block to arrange with the remaining friends outside, and each outside lineup has k!\picky{k!} ways to order the friends inside the box.

Interactive c4

Key concepts

Counting arrangements without repetition always comes back to tracking how many choices are available as you fill slots one by one:

Check whether repetition is allowed first

If items can be reused, the pool never shrinks (a 4-digit PIN from 1010 digits is 104\howmany{10^4}). Only use factorials and shrinking slots when each item can be used at most once.

All nn items vs. kk items out of nn

Lining up all nn distinct items takes nn slots and multiplies all the way down to 11, giving n!n! (with 0!=10! = \howmany{1}). Lining up only kk items out of nn stops after kk slots (3 books out of 10 gives 10×9×810 \times 9 \times 8), which in factorial form is P(n,k)=n!(n−k)!P(n, k) = \frac{n!}{\leftover{(n - k)!}}.

Factorial algebra

If factorials with variables sit in a fraction like (n+1)!(n−1)!\frac{(n + 1)!}{\leftover{(n - 1)!}}, expand the larger factorial from the front until its tail cancels the smaller one: (n+1)n(n + 1)n. If a single n!n! is multiplied by a number like 3×n!=360\operation{3} \times n! = 360, don't expand it: divide by 3\operation{3} to isolate n!=120n! = 120 first.

Restrictions on positions vs. neighbors

If a rule restricts where someone can go, fill the picky slot first (4-digit numbers from 0–50\text{–}5: fill the non-zero first digit before putting 00 back in the pool, giving 5×5×4×3\picky{5} \times 5 \times 4 \times 3). If a rule restricts who stays together, glue the group into one block and multiply outside arrangements by inside arrangements (2 friends glued among 5 gives 4!×2!4! \times \picky{2!}).

6

Practice

1

Six different paintings are to be hung in a single row along a gallery wall. In how many different orders can all six paintings be hung?

Draw 66 slots for the 66 spots on the wall and see how many paintings remain available as you move from left to right.

Filling the 66 slots without repeating a painting shrinks the pool by 11 each time:
6!\displaystyle 6! =6×5×4×3×2×1\displaystyle = 6 \times 5 \times 4 \times 3 \times 2 \times 1 =720\displaystyle = \howmany{720}
(Watch out: don't keep all 66 choices in every slot to get 66=46,6566^6 = \leftover{46{,}656}, because once a painting is on the wall it cannot be hung again; and multiply the slot choices rather than adding them to get 21\leftover{21}.)
Total: 720\howmany{720}.
2

A race has 1212 runners and no ties are possible. In how many different ways can gold, silver, and bronze medals be awarded to 1st, 2nd, and 3rd place?

How many medal slots are you filling out of the 1212 runners?

Draw 33 slots for gold, silver, and bronze, and multiply down for those 33 spots only:
12×11×10\displaystyle 12 \times 11 \times 10 =1,320\displaystyle = \howmany{1{,}320}
(Watch out: don't keep multiplying all the way down to 11 to get 12!=479,001,60012! = \leftover{479{,}001{,}600}, because the 9\leftover{9} runners who don't win a medal don't have slots.)
Total: 1,320\howmany{1{,}320}.
3

Write P(6,6)P(6, 6) as a fraction of factorials using P(n,k)=n!(n−k)!P(n, k) = \frac{n!}{\leftover{(n - k)!}}, and evaluate it using the definition of 0!0!.

Substitute n=6n = 6 and k=6k = 6 into the fraction and remember how many ways there are to arrange zero leftover items.

Substituting n=6n = 6 and k=6k = 6 leaves 0!\leftover{0!} in the denominator:
P(6,6)\displaystyle P(6, 6) =6!(6−6)!\displaystyle = \frac{6!}{\leftover{(6 - 6)!}} =6!0!\displaystyle = \frac{6!}{\leftover{0!}}
Using 6!=7206! = \howmany{720} and 0!=1\leftover{0!} = \howmany{1} (not 0\leftover{0}, which would make the fraction 7200\frac{720}{\leftover{0}} undefined):
7201\displaystyle \frac{720}{1} =720\displaystyle = \howmany{720}
4

Simplify the factorial fraction (n+2)!(n−1)!\frac{(n + 2)!}{(n - 1)!}.

Which factorial is larger? Pull factors off its front one by one until the remaining tail matches the denominator.

Expand (n+2)!(n + 2)! three steps down until you reach (n−1)!\leftover{(n - 1)!}:
(n+2)!(n−1)!=(n+2)(n+1)n(n−1)!(n−1)!=(n+2)(n+1)n\displaystyle \begin{aligned}&\frac{(n + 2)!}{\leftover{(n - 1)!}} \\ &= \frac{(n + 2)(n + 1)n\leftover{\cancel{(n - 1)!}}}{\leftover{\cancel{(n - 1)!}}} \\ &= (n + 2)(n + 1)n\end{aligned} \quad
(Watch out: don't stop one step early at (n+2)(n+1)\leftover{(n + 2)(n + 1)} by skipping the factor of nn between n+1n + 1 and n−1n - 1.)
Result: (n+2)(n+1)n(n + 2)(n + 1)n.
5

Solve for nn: 4×n!=2,8804 \times n! = 2{,}880.

Isolate n!n! on one side before trying to figure out what nn is.

Divide both sides by 4\operation{4} first (don't multiply the 44 inside the factorial to write (4n)!=2,880\leftover{(4n)!} = 2{,}880):
n!\displaystyle n! =2,8804\displaystyle = \frac{2{,}880}{\operation{4}} =720\displaystyle = 720
Since 6!=7206! = 720, we get:
n\displaystyle n =6\displaystyle = 6
6

Solve for nn: P(n,2)=90P(n, 2) = 90.

Write P(n,2)P(n, 2) as the product of 22 slots starting at nn.

Filling two slots gives the product of two consecutive whole numbers:
n(n−1)\displaystyle n(n - 1) =90\displaystyle = 90
Since 10×9=9010 \times 9 = 90, nn is the larger starting number (watch out for picking the second factor 9\leftover{9} instead of 1010):
n\displaystyle n =10\displaystyle = 10
7

Seven performers, 33 comedians and 44 musicians, are scheduled to perform one after another. If the show must both open and close with a comedian, how many different lineups are possible?

Fill the opening and closing slots first, then count how many total performers are left for the middle slots.

Fill the two picky slots first: 3\picky{3} choices for the opening comedian and 2\picky{2} choices for the closing comedian. The third unused comedian joins the 44 musicians, leaving 55 performers for the 55 middle slots (5!=1205! = \howmany{120} ways; watch out for only arranging the 44 musicians in the middle to get 3×2×4!=1443 \times 2 \times 4! = \leftover{144}):
3×2×5!\displaystyle \picky{3} \times \picky{2} \times 5! =3×2×120\displaystyle = \picky{3} \times \picky{2} \times \howmany{120} =720\displaystyle = \howmany{720}
8

Using the digit tiles 0,1,2,3,4,5,60, 1, 2, 3, 4, 5, 6 without repeating any digits, how many 4-digit odd numbers can you make?

Both the last slot (odd) and the first slot (non-zero) are picky. Fill the last slot first so you know how many non-zero digits remain for the first slot.

Fill the pickiest last slot first with an odd digit (1,3,\picky{1, 3,} or 5\picky{5}, giving 3\picky{3} choices). Next, fill the picky first slot, which cannot be 00 and cannot be the odd digit just used (5\picky{5} choices left out of 77). Then put 00 back in the pool for the middle two slots, giving 55 choices and 44 choices (forgetting to put 00 back in for the second slot gives 5×4×3×3=1805 \times 4 \times 3 \times 3 = \leftover{180}, and filling the first slot before the last slot gives 6×5×4×3=3606 \times 5 \times 4 \times 3 = \leftover{360}):
5×5×4×3\displaystyle \picky{5} \times 5 \times 4 \times \picky{3} =300\displaystyle = \howmany{300}
9

Six friends (Alice, Bob, Charlie, David, Eve, and Frank) sit in a row of 66 seats. If Alice, Bob, and Charlie must sit together in three consecutive seats, how many seating arrangements are possible?

Glue Alice, Bob, and Charlie into a single block and count how many outside objects you have to arrange.

Glue Alice, Bob, and Charlie into one block [ABC]\picky{[ABC]}, giving 44 outside objects ([ABC],D,E,F\picky{[ABC]}, D, E, F) that can be arranged in 4!=244! = \howmany{24} ways. Then multiply by the 3!=6\picky{3!} = \picky{6} ways Alice, Bob, and Charlie can be ordered inside their block (watch out for leaving off the inside orders to get 24\leftover{24}, or multiplying by 33 instead of 3!3! to get 72\leftover{72}):
4!×3!\displaystyle 4! \times \picky{3!} =24×6\displaystyle = \howmany{24} \times \picky{6} =144\displaystyle = \howmany{144}
10

A shelf holds 88 distinct books: 44 mystery novels, 33 biographies, and 11 dictionary. If all 44 mystery novels must stay together and all 33 biographies must stay together, how many ways can the 88 books be arranged on the shelf?

Make one glued block for the mysteries and a second glued block for the biographies, and don't forget the dictionary when counting outside objects.

The mystery block, the biography block, and the dictionary form 33 outside objects, which can be ordered in 3!=63! = \howmany{6} ways (leaving out the dictionary and using 2!2! gives 288\leftover{288}, and forgetting to arrange the outside objects altogether gives 4!×3!=1444! \times 3! = \leftover{144}). Multiply by 4!=24\picky{4!} = \picky{24} ways to order the mysteries inside their block and 3!=6\othergroup{3!} = \othergroup{6} ways to order the biographies inside theirs:
3!×4!×3!\displaystyle 3! \times \picky{4!} \times \othergroup{3!} =6×24×6\displaystyle = \howmany{6} \times \picky{24} \times \othergroup{6} =864\displaystyle = \howmany{864}