The sum and product rules
Every counting formula in this lesson comes from two simple rules.
Sum rule: if a task can be done in \(m\) ways or in \(n\) ways, with no way counted in both lists, it can be done in \(m + n\) ways.
Product rule: if a task is done in two stages, with \(m\) ways for the first and \(n\) ways for the second whatever the first choice was, it can be done in \(mn\) ways.
A code made of one letter followed by two digits: \(26 \times 10 \times 10 = 2600\) codes (product rule). A lunch of either one of 4 sandwiches or one of 3 wraps: \(4 + 3 = 7\) choices (sum rule). Words like "and then" signal a product; "either ... or" with no overlap signals a sum.
Permutations: order matters
A permutation is an arrangement, where the order of the objects counts. By the product rule, arranging \(r\) of \(n\) different objects in a row can be done in \(n(n-1)\cdots(n-r+1)\) ways.
\(r\) of \(n\) distinct objects, no repetition: \({}^nP_r = \dfrac{n!}{(n-r)!}\). All \(n\) of them: \(n!\).
With repetition allowed: \(n^r\).
\(n\) objects with \(p\) alike of one kind, \(q\) alike of another, and so on: \(\dfrac{n!}{p!\,q!\cdots}\).
\(n\) distinct objects round a circle: \((n-1)!\). If turning the circle over gives the same arrangement (a necklace or garland): \(\dfrac{(n-1)!}{2}\).
Why divide by \(p!\)? If the \(p\) alike objects were labelled, there would be \(n!\) arrangements, and each unlabelled arrangement would appear \(p!\) times, once for each order of the labels. For the circle, the \(n\) rotations of a seating are the same seating, so \(n!\) is divided by \(n\). Equivalently, fix one person's seat and arrange the other \(n - 1\).
Combinations: order does not matter
A combination is a selection, where only which objects are chosen counts. Each selection of \(r\) objects can be arranged in \(r!\) orders, so
\[{}^nC_r = \binom{n}{r} = \frac{n!}{r!\,(n-r)!} = \frac{{}^nP_r}{r!}\]
\(\dbinom{n}{r} = \dbinom{n}{n-r}\) and \(\dbinom{n}{r} = \dbinom{n-1}{r-1} + \dbinom{n-1}{r}\) (Pascal's rule).
With repetition (stars and bars)
Choosing \(r\) items from \(n\) types, repeats allowed: \(\dbinom{n + r - 1}{r}\). This also counts the non-negative integer solutions of \(x_1 + x_2 + \cdots + x_n = r\).
Stars and bars: write the \(r\) items as stars and use \(n - 1\) bars to split them into \(n\) groups, one per type. For example, with \(n = 4\) and \(r = 5\), \(\star\star \mid \star \mid \mid \star\star\) means 2, 1, 0, 2. Every choice is a row of \(r + n - 1\) symbols, and you only decide where the \(n - 1\) bars go.
The link with the binomial theorem
\[(a + b)^n = \sum_{r=0}^{n} \binom{n}{r} a^{n-r} b^r\]
Expanding \((a + b)^n\) means choosing \(a\) or \(b\) from each of the \(n\) brackets. A term \(a^{n-r}b^r\) comes from choosing \(b\) in \(r\) of the brackets, which can be done in \(\binom{n}{r}\) ways. Putting \(a = b = 1\) gives \(\sum_r \binom{n}{r} = 2^n\), the number of subsets of an \(n\)-element set. The same coefficients appear in the binomial distribution.
| Choosing \(r\) from \(n\) | Repetition not allowed | Repetition allowed |
|---|---|---|
| Order matters | \({}^nP_r = \dfrac{n!}{(n-r)!}\) | \(n^r\) |
| Order does not matter | \(\dbinom{n}{r}\) | \(\dbinom{n+r-1}{r}\) |
Solved examples
Example 1: PINs
EasyHow many 4-digit PINs can be made from the digits 0 to 9? How many have no repeated digit?
- Repetition allowed: \(10^4 = 10000\).
- No repetition: \(10 \times 9 \times 8 \times 7 = {}^{10}P_4 = 5040\).
Answer10000 PINs; 5040 with all digits different.
Example 2: Repeated letters
EasyHow many arrangements are there of the letters of MATHS? Of BANANA?
- MATHS has 5 different letters: \(5! = 120\).
- BANANA has 6 letters with A three times and N twice: \(\dfrac{6!}{3!\,2!} = \dfrac{720}{12} = 60\).
Answer120 and 60
Example 3: ENGINEERING
MediumHow many arrangements are there of the letters of ENGINEERING? In how many do the three E's come together?
- 11 letters: E three times, N three times, G twice, I twice, R once.
- Total: \[\frac{11!}{3!\,3!\,2!\,2!} = \frac{39916800}{144} = 277200\]
- Glue EEE into one block. Now arrange 9 objects (the block, N three times, G twice, I twice, R): \[\frac{9!}{3!\,2!\,2!} = \frac{362880}{24} = 15120\]
Answer277200 arrangements; in 15120 of them the E's are together.
Example 4: A committee
MediumA committee of 5 is chosen from 7 men and 5 women. In how many ways can this be done if it must have at least 2 women?
- Split by the number of women (sum rule): \[\binom{5}{2}\binom{7}{3} + \binom{5}{3}\binom{7}{2} + \binom{5}{4}\binom{7}{1} + \binom{5}{5}\binom{7}{0}\]
- \(= 10 \cdot 35 + 10 \cdot 21 + 5 \cdot 7 + 1 \cdot 1 = 350 + 210 + 35 + 1\).
- Check with the complement: \(\binom{12}{5} - \binom{7}{5} - \binom{5}{1}\binom{7}{4} = 792 - 21 - 175 = 596\).
Answer596 committees
Example 5: Round a table
MediumIn how many ways can 6 people sit round a circular table? In how many of these do two particular people, A and B, sit together?
- Fix one person's seat and arrange the other 5: \((6 - 1)! = 120\).
- Treat A and B as one unit. Now 5 units go round the table: \(4! = 24\) ways.
- Inside the unit, A and B can swap: \(\times 2\).
Answer120 seatings; A and B are together in \(24 \times 2 = 48\) of them.
Example 6: Integer solutions
MediumHow many solutions does \(x + y + z = 10\) have in non-negative integers? In positive integers?
- Stars and bars with \(n = 3\) types and \(r = 10\): \(\dbinom{12}{2} = 66\).
- For positive integers, first give 1 to each variable. Then \(x' + y' + z' = 7\) with \(x', y', z' \ge 0\): \(\dbinom{9}{2} = 36\).
Answer66 non-negative solutions; 36 positive solutions.
Example 7: Ice creams
Exam levelA shop sells 4 flavours of ice cream. In how many ways can you buy 6 scoops, if order does not matter and flavours can repeat?
- This is choosing \(r = 6\) items from \(n = 4\) types with repetition.
- Equivalently, the number of solutions of \(x_1 + x_2 + x_3 + x_4 = 6\) in non-negative integers.
- \(\dbinom{4 + 6 - 1}{6} = \dbinom{9}{6} = \dbinom{9}{3} = 84\).
Answer84 ways
Example 8: No two girls together
Exam levelIn how many ways can 5 boys and 3 girls sit in a row so that no two girls are next to each other?
- Seat the boys first: \(5! = 120\) ways.
- This creates 6 gaps (one before, one after and four between): _ B _ B _ B _ B _ B _.
- Put the 3 girls in 3 different gaps, in order: \({}^6P_3 = 6 \times 5 \times 4 = 120\).
- Product rule: \(120 \times 120\).
Answer14400 arrangements
Before you touch a formula, ask two questions: does the order matter, and can things repeat? The answers pick the cell of the table above. For any question that says "at least", also count the complement and subtract. It is often shorter, and it is a free check on your first answer, as in Example 4.
Common mistakes
1. Using permutations for a selection
Choosing 3 students from 10 for a committee: wrong \({}^{10}P_3 = 720\), which counts each committee \(3! = 6\) times. Right: \(\binom{10}{3} = 120\).
2. Double counting "at least one"
Committees of 5 from 7 men and 5 women with at least one woman. Wrong: pick one woman (5 ways), then any 4 of the remaining 11, giving \(5 \times 330 = 1650\). A committee with two women is counted twice, once for each woman picked "first". Right: \(\binom{12}{5} - \binom{7}{5} = 792 - 21 = 771\).
3. Using \(n!\) for a round table
6 people round a table: wrong \(6! = 720\). Rotating everyone one seat gives the same seating, so each seating was counted 6 times. Right: \(5! = 120\).
Practice questions
Try each one on paper before you open the answer.
Q1How many 3-letter strings can be made from the 26 letters if letters may repeat? If they may not?
\(26^3 = 17576\) with repetition; \(26 \times 25 \times 24 = 15600\) without.
Q2How many distinct arrangements are there of the letters of LEVEL?
5 letters with L twice and E twice: \(\dfrac{5!}{2!\,2!} = 30\).
Q3A team of 4 is chosen from 10 players, and one particular player must be in it. How many teams are possible?
Put that player in, then choose the other 3 from the remaining 9: \(\binom{9}{3} = 84\).
Q4In how many ways can 8 different beads be strung into a necklace?
Circular, and the necklace can be turned over: \(\dfrac{(8-1)!}{2} = \dfrac{5040}{2} = 2520\).
Q5How many non-negative integer solutions does \(a + b + c + d = 7\) have?
\(\dbinom{7 + 4 - 1}{3} = \dbinom{10}{3} = 120\).
Q6Find the coefficient of \(x^2y^3\) in \((x + y)^5\), and the sum of all the coefficients.
Choose \(y\) from 3 of the 5 brackets: \(\binom{5}{3} = 10\). The sum of the coefficients is \((1 + 1)^5 = 32\).
Bring it to a free demo class and work through it with Vipul Sir. Book on WhatsApp.
Frequently asked questions
What is the difference between a permutation and a combination?
A permutation is an arrangement, so order matters: AB and BA are different. A combination is a selection, so order does not matter: AB and BA are the same. That is why \({}^nP_r = r! \cdot {}^nC_r\).
What is the formula for nCr?
\({}^nC_r = \dfrac{n!}{r!\,(n-r)!}\). For example \({}^{5}C_2 = \dfrac{120}{2 \times 6} = 10\).
What is the stars and bars method?
A way of counting selections with repetition. Choosing \(r\) items from \(n\) types is the same as placing \(n - 1\) bars among \(r\) stars, which can be done in \(\binom{n+r-1}{r}\) ways.
Why is a circular permutation (n - 1)!?
Because the \(n\) rotations of a seating around a circle are the same seating. Dividing \(n!\) by \(n\) gives \((n-1)!\). You get the same answer by fixing one person and arranging the rest.