Counting — The Fundamental Principle of Counting
2640 words
13 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Counting — The Fundamental Principle of Counting ## 🎯 Learning Objectives After completing this topic, you will be able to: - Apply the **fundamental counting principle** (multiplication rule) to count outcomes - Apply the **addition rule** for mutually exclusive choices - Compute **factorials** and understand th...

Counting — The Fundamental Principle of Counting
🎯 Learning Objectives
After completing this topic, you will be able to:
- Apply the fundamental counting principle (multiplication rule) to count outcomes
- Apply the addition rule for mutually exclusive choices
- Compute factorials and understand their combinatorial meaning
- Distinguish between situations requiring the multiplication rule vs addition rule
- Solve basic counting problems with multiple steps
📋 Prerequisites
- Basic arithmetic: multiplication, addition
- No probability knowledge needed — this is the foundation for probability
- BSMA1001-maths-1: Basic set operations (union, intersection) help visualize counting
📖 Core Content
9.1 Intuition: Why Counting Matters
Before we can compute probabilities, we need to count how many possible outcomes exist.
Example: If you roll a die and flip a coin, how many possible outcomes exist? 6 (die) × 2 (coin) = 12 outcomes. The probability of getting a "heads and a 3" is 1/12 because there's 1 favorable outcome out of 12 total.
Counting is the foundation of probability. Without counting, we can't compute probabilities for equally likely outcomes.
Everyday analogy: You're at a restaurant choosing a meal: 3 appetizers × 4 main courses × 2 desserts = 24 possible three-course meals. That's counting! 🔑 Key Insight: Most counting problems break down into: "How many ways can we do step 1?" × "How many ways can we do step 2?" × ...
9.2 The Fundamental Counting Principle (Multiplication Rule)
9.2.1 Intuition
If a task can be broken into a sequence of steps, and each step has a certain number of choices, the total number of ways to complete the task is the product of the number of choices at each step.
Why multiplication? For each choice in step 1, you have all the choices in step 2, and so on. So you multiply.
9.2.2 Formal Statement
n1×n2×⋯×nkIf task A can be done in m ways and, for each of those ways, task B can be done in n ways, then the two tasks together can be done in m × n ways. This extends to any number of tasks: if there are k steps with n1,n2,...,nk options each, the total number of outcomes is:
9.2.3 Worked Examples
Example 1 (Easy): A restaurant offers 4 appetizers, 6 main courses, and 3 desserts. How many three-course meals?
Example 2 (Medium): A license plate has 3 letters followed by 3 digits. How many possible plates (letters and digits can repeat)?
Example 3 (Harder): How many 4-digit PIN codes exist if the first digit cannot be 0 and no digit repeats?
- Step 1 (first digit): 9 choices (1-9)
- Step 2 (second digit): 9 choices (0-9, minus the one used)
- Step 3 (third digit): 8 choices
- Step 4 (fourth digit): 7 choices
9.3 The Addition Rule
9.3.1 Intuition
Sometimes we don't have sequential steps — we have alternative choices. If you can do task A OR task B, the total number of ways is the sum of the ways to do each.
9.3.2 Formal Statement
If task A can be done in m ways and task B can be done in n ways, and the tasks are mutually exclusive (they can't both happen), then the number of ways to do "A or B" is m + n.
9.3.3 Worked Examples
Example 1: You can choose either a sandwich (5 options) OR a salad (4 options) for lunch. How many food choices?
Example 2: A password must be either 4 digits OR 3 letters. How many possible passwords?
- 4-digit passwords: 104=10,000
- 3-letter passwords: 263=17,576
- Total: 10,000+17,576=27,576
9.4 Combining Multiplication and Addition
Most real problems combine both rules.
Example: Choosing an outfit: You have 3 shirts and 4 pants. Additionally, you have 2 dresses. How many total outfit choices?
- Pants outfits: 3×4=12
- Dress outfits: 2
- Total: 12+2=14 Flowchart for choosing counting rule: (Diagram)
9.5 Factorial Notation
9.5.1 Intuition
A factorial counts the number of ways to arrange n distinct objects in order. If you have 5 books, how many ways can you arrange them on a shelf?
For the first position: 5 choices For the second: 4 choices ...and so on.
This product is called "5 factorial" and written as 5!.
9.5.2 Definition
n!=n×(n−1)×(n−2)×⋯×2×1Special cases:
- 0!=1 (by convention — there's exactly one way to arrange nothing)
- 1!=1
9.5.3 Examples
| n | n! | Meaning |
|---|---|---|
| 0 | 1 | One way to arrange nothing |
| 1 | 1 | One way to arrange 1 item |
| 2 | 2 × 1 = 2 | Two ways: AB, BA |
| 3 | 3 × 2 × 1 = 6 | 6 arrangements of 3 items |
| 4 | 4 × 3 × 2 × 1 = 24 | 24 arrangements |
| 5 | 5 × 4 × 3 × 2 × 1 = 120 | 120 arrangements |
Factorials grow very fast: 10!=3,628,800
9.6 Worked Examples
Example 1: Multiple-Step Counting (Easy)
Scenario: A ice cream shop has 3 cone types (sugar, waffle, cup), 8 flavors, and 5 toppings. How many different ice cream creations (1 cone + 1 flavor + 1 topping)?
Solution:
This is a sequential choice: cone → flavor → topping
Example 2: With Restrictions (Medium)
Scenario: How many 4-digit numbers can be formed from digits 1-9 if:
- a) Digits can repeat
- b) Digits cannot repeat
- c) The number must be even and digits cannot repeat Solution: a) With repetition: 9×9×9×9=94=6,561 b) Without repetition: 9×8×7×6=3,024 c) Even, no repetition:
- The last digit must be even: 2, 4, 6, 8 (4 choices)
- First digit: can't be 0 and can't be the last digit → up to 8 choices (9 digits total - 1 used)
- But we need to be careful — the restrictions interact Let's do it step by step:
- Step 1: Choose last digit (must be even): 4 choices (2, 4, 6, 8)
- Step 2: Choose first digit: can't be 0, can't be the chosen last digit → 9 - 1 = 8 choices (from 1-9 minus the last digit)
- Step 3: Choose second digit: any remaining digit from 0-9 except the two used → 10 - 2 = 8 choices
- Step 4: Choose third digit: 10 - 3 = 7 choices
Example 3: Hotel Room Numbering (Harder)
Scenario: A hotel numbers rooms with 3 digits. The first digit is the floor (1-8), the second digit indicates wing (A=1, B=2, so 1-2), the third digit is the room number on that floor (1-20).
a) How many total rooms?
b) How many rooms on floors 5-8?
- Floors 5-8: 4 floors
- 4×2×20=160 c) If room 000 is the lobby, and rooms 100-199 are reserved for staff, how many guest rooms?
- Total: 320
- Staff: 1×2×20=40 (floor 1 rooms)
- Lobby: 1 room (000)
- Guest rooms: 320−40−1=279
9.7 Edge Cases & Gotchas
When Order Doesn't Matter (Preview)
The multiplication rule assumes order matters. If you're selecting a committee of 3 people from 10, and order doesn't matter (choosing {A,B,C} is the same as {C,B,A}), you need combinations — which we'll cover in the next topic.
The "At Least" Problem
Often we need to count outcomes with conditions like "at least one." It's often easier to count the complement (none) and subtract.
Example: Roll a die 3 times. What's the probability of getting at least one 6?
- Total outcomes: 63=216
- Outcome with no 6s: 53=125
- Outcomes with at least one 6: 216−125=91
Overlapping Events
The addition rule requires mutually exclusive events. If events can overlap, you need the inclusion-exclusion principle:
9.8 Why This Matters
Counting is the foundation of probability:
- Week 6 (Permutations & Combinations): Extends counting to arrangements and selections
- Week 7 (Probability): P(event) = favorable / total (needs counting)
- Week 11 (Distributions): Binomial coefficient in binomial distribution
- BSMA1004 (Stats 2): Counting in hypothesis testing
📐 Key Formulas / Concepts
| Concept | Formula | When to Use |
|---|---|---|
| Multiplication Rule | n1×n2×⋯×nk | Sequential choices |
| Addition Rule | m+n | Mutually exclusive alternatives |
| Factorial | n!=n×(n−1)×⋯×1 | Arranging n distinct items |
| Complement Counting | Total−Not(A) | "At least" problems |
| Inclusion-Exclusion | $ | A \cup B |
⚠️ Common Pitfalls
Pitfall 1: Using Multiplication When You Should Add
The mistake: A menu has 3 appetizers and 5 main courses. Someone says there are 3 × 5 = 15 "meal options."
Why it happens: The word "and" makes you think multiply.
Correction: If you choose ONE appetizer OR ONE main course (not both), it's 3 + 5 = 8. If you choose both, it's 3 × 5 = 15. Ask: "Are these sequential choices (both) or alternatives (one or the other)?"
Pitfall 2: Forgetting Restrictions Interact
The mistake: Counting 4-digit numbers with distinct digits as 9 × 9 × 8 × 7 = 4,536 without checking if the restrictions are correctly handled.
Why it happens: The first step seems clear (9 choices), but the later steps depend on earlier choices.
Correction: Always consider the most restrictive condition first. In Example 2c (even numbers), we handled the last digit restriction first because it was the most restrictive. Then dealt with the remaining positions.
Pitfall 3: Not Considering 0 as a Digit
The mistake: Forgetting that 0 is a digit but can't lead a number.
Why it happens: 0 is often overlooked.
Correction: Always note: "First digit cannot be 0." After that, 0 is available for other positions.
📝 Practice Questions
</details> > **Q2: Addition Rule** > > You can travel to work by bus (3 routes), train (2 routes), or bike (1 route). How many total travel options? > > <details> <strong>Solution</strong> > > $3 + 2 + 1 = 6 \text{ routes}$ > > $\boxed{6}$ </details> > **Q3: Combined Rules** > > </strong> > > A pizza place offers: build-your-own (choose 1 crust from 3, 1 sauce from 2, and any number of 8 toppings) OR a specialty pizza (10 pre-made options). How many total choices? > > <details> <strong>Solution</strong> > > **Build-your-own:** For each topping, you choose yes/no → 2 choices per topping $3 \times 2 \times 2^8 = 3 \times 2 \times 256 = 1,536$ > > **Specialty:** 10 choices > > **Total:** $1,536 + 10 = 1,546$ > > $\boxed{1,546 \text{ total pizza choices}}$ </details> > **Q4: Factorial Calculation** > > </strong> > > Compute: a) 6! b) 7!/5! c) 10!/8! > > <details> <strong>Solution</strong> > > a) $6! = 6 \times 5 \times 4 \times 3 \times 2 \times 1 = 720$ > > b) $\frac{7!}{5!} = \frac{7 \times 6 \times 5!}{5!} = 7 \times 6 = 42$ > > c) $\frac{10!}{8!} = \frac{10 \times 9 \times 8!}{8!} = 10 \times 9 = 90$ > > $\boxed{720,\ 42,\ 90}$ </details> > **Q5: Digit Restrictions** > > </strong> > > How many 3-digit numbers can be formed using digits 1-9 if: a) Digits can repeat b) Digits cannot repeat c) The number is odd and digits cannot repeat > > <details> <strong>Solution</strong> > > **a) With repetition:** $9 \times 9 \times 9 = 9^3 = 729$ > > **b) No repetition:** $9 \times 8 \times 7 = 504$ > > **c) Odd, no repetition:** > > - Last digit must be odd: 1, 3, 5, 7, 9 (5 choices) > - First digit: any remaining digit from 1-9 except the last → 8 choices > - Middle digit: any remaining from 0-9 except first and last → 10 - 2 = 8 choices > > $5 \times 8 \times 8 = 320$ > > $\boxed{729,\ 504,\ 320}$ </details> > **Q6: Password Problem** > > </strong> > > A password must be 4-6 characters long, using lowercase letters (a-z). How many possible passwords? > > <details> <strong>Solution</strong> > > 4 characters: $26^4 = 456,976$ 5 characters: $26^5 = 11,881,376$ 6 characters: $26^6 = 308,915,776$ > > Total: $456,976 + 11,881,376 + 308,915,776 = 321,254,128$ > > $\boxed{321,254,128 \text{ passwords}}$ </details> > **Q7: Complement Counting** > > </strong> > > You roll a die 4 times. How many outcomes have at least one 6? > > <details> <strong>Solution</strong> > > Total outcomes: $6^4 = 1,296$ Outcomes with no 6: $5^4 = 625$ Outcomes with at least one 6: $1,296 - 625 = 671$ > > $\boxed{671}$ </details> > **Q8: Inclusion-Exclusion** > > </strong> > > In a school, 30 students take Statistics, 25 take Calculus, and 12 take both. How many students take Statistics or Calculus? > > <details> <strong>Solution</strong> > > $|S \cup C| = |S| + |C| - |S \cap C| = 30 + 25 - 12 = 43$ > > $\boxed{43 \text{ students}}$ </details> > **Q9: Real-World Application** > > </strong> > > A clothing company makes shirts in 5 sizes (S, M, L, XL, XXL), 8 colors, and 3 sleeve lengths. How many unique SKUs (stock-keeping units) do they need? If they discontinue XXL, how many SKUs are lost? > > <details> <strong>Solution</strong> > > **Total SKUs:** $5 \times 8 \times 3 = 120$ > > **After removing XXL:** $4 \times 8 \times 3 = 96$ > > **SKUs lost:** $120 - 96 = 24$ > > Alternatively: $1 \times 8 \times 3 = 24$ (the XXL size alone) > > $\boxed{120 \text{ total},\ 24 \text{ lost}}$ </details> > **Q10: Complex Counting** > > </strong> > > How many 5-digit numbers (first digit non-zero) are palindromes (read same forwards and backwards)? > > <details> <strong>Solution</strong> > > A 5-digit palindrome looks like: ABCBA > > - A (first digit): 1-9 → 9 choices > - B (second digit): 0-9 → 10 choices > - C (middle digit): 0-9 → 10 choices > - D (fourth digit) = B (same as second) → 1 choice > - E (fifth digit) = A (same as first) → 1 choice > > $9 \times 10 \times 10 \times 1 \times 1 = 900$ > > $\boxed{900 \text{ palindromic 5-digit numbers}}$ </details> * * * ## 🔗 Cross-References - **Next topic:** [Permutations](/notes/01-foundation-bsma1002-stats-1-week06-09-permutations) — arranging items in order - **After that:** [Combinations](/notes/01-foundation-bsma1002-stats-1-week06-10-combinations) — selecting items without order - **Week 7 (Probability):** Using counting to find probabilities - **Week 11 (Binomial Distribution):** The binomial coefficient ${n \choose k}$ - **BSMA1001-maths-1:** Set theory foundations [Join Discord](https://discord.gg/gE2m4Qrdqv) [Previous**Correlation**](/notes/01-foundation-bsma1002-stats-1-week04-07-correlation)[Next**Permutations**](/notes/01-foundation-bsma1002-stats-1-week06-09-permutations)Q1: Basic Multiplication Rule<details> <strong>Solution</strong>A store sells 5 different t-shirts, 3 different jeans, and 4 different shoes. How many outfits (1 shirt + 1 jeans + 1 shoes) can you make?5×3×4=60 outfits60