Maths for Machines
0 of 5 lessons done100 questions

Lesson 1 of 5

The addition and multiplication rules

Add counts for separate alternatives; multiply counts for consecutive choices.

Core lesson · about 6 minutes · 3 guided parts

A student may choose a bus or a bicycle to reach school, so those possibilities add. After arriving, the student chooses one lunch and one drink, so those possibilities multiply.

Your learning route

Build the idea one piece at a time

  1. The addition rule
  2. The multiplication rule and tree diagrams
  3. Design a count before touching a calculator
The addition and multiplication rules, made visible
each full path makes one choice at every stagestartAB2 × 3 = 6 complete paths

The addition rule

When exactly one route is chosen, count each non-overlapping route and add.

If option sets cannot happen together, the total number of choices is their sum.

If option sets overlap, subtract the overlap once or first split them into disjoint cases.

Clear cases are a counting tool: each valid outcome must appear in one case, never zero cases and never two.

Addition works directly only after cases are made disjoint. Counting students who play cricket and students who play football requires subtracting those who play both unless the groups were separated first.

A good case split covers every valid outcome exactly once. Splitting integers into even and odd works because every integer is in one of those cases and none is in both.

Sometimes the easiest addition counts an unwanted group first. If 40 lunches are vegetarian or non-vegetarian and 13 are vegetarian, the other disjoint case has 40−13=27 lunches.

In symbolsdisjoint A or B: |A∪B|=|A|+|B|

Worked example

A shelf has 7 novels and 5 biographies. In how many ways can one book of either type be chosen?

  1. Choosing a novel and choosing a biography are separate alternatives.
  2. There are 7 choices in the novel case.
  3. There are 5 choices in the biography case.
  4. Add: 7 + 5 = 12.

Answer: 12 ways

The multiplication rule and tree diagrams

For a journey with stages, each complete path picks one branch at every stage.

If stage one has m choices and each leads to n choices at stage two, there are mn complete outcomes.

The number of later choices may depend on earlier choices; a tree diagram exposes those changing branch counts.

A decision tree is also a proof that outcomes are complete and not double-counted.

The multiplication rule counts complete paths through stages. Three shirt choices followed by two trouser choices produce 3×2=6 outfits because every shirt can pair with every trouser.

When branch counts change, multiply along each path and then add across separate branches. A tree makes those unequal later choices visible instead of forcing one incorrect product.

Label each tree leaf with the full outcome, such as red-large-card, rather than only the final choice. The labels reveal missing paths and accidental duplicates.

In symbolsm choices then n choices = mn outcomes

Worked example

A code uses one of 3 letters followed by one of 4 digits. Repetition is allowed. How many codes exist?

  1. Choose the letter in 3 ways.
  2. For each letter, choose the digit in 4 ways.
  3. Every code contains both choices.
  4. Multiply: 3 × 4 = 12.

Answer: 12 codes

Practical deep dive for this lesson

Design a count before touching a calculator

A correct count assigns every valid outcome to exactly one path through a decision process, so nothing is missed and nothing is counted twice.

Draw the decision as stages or cases. Use cases when exactly one alternative route is taken; use stages when several choices are made in sequence.

The addition rule combines disjoint cases. If an outcome can belong to two cases, first repair the overlap or use inclusion–exclusion.

The multiplication rule combines stages. If every first-stage choice can be followed by every listed second-stage choice, multiply the numbers of choices.

A tree diagram makes the rules visible: branches from one point are alternatives that add, while a complete root-to-leaf path contains stages that multiply.

Restrictions change counts at the exact stage where they become active. After choosing one object without replacement, the number available at the next stage falls by one.

Counting avoids listing enormous spaces. A login system can measure how many possible codes exist, and an experiment can estimate how many configurations it would need to test.

The result helps choose an algorithm: a search through 120 possibilities may be practical, while a search through 10²⁰ needs structure, sampling, or pruning.

State whether choices can repeat and whether order matters. Those two questions usually determine the correct counting model.

In symbolstotal leaves = choices at stage 1 × choices at stage 2 × ⋯

Worked example

A badge code uses one letter from {A,B,C,D}, then two different digits from 0–9, followed by either a star or a circle. How many codes are possible?

  1. Separate the construction into four stages: letter, first digit, second digit, and final symbol.
  2. The letter stage has 4 choices.
  3. The first digit has 10 choices, including zero.
  4. The second digit must differ from the first, so only 9 choices remain.
  5. The final symbol has 2 choices.
  6. Every allowed choice at one stage can be combined with every allowed choice at the next, so use multiplication.
  7. Calculate 4×10×9×2=720.
  8. No division is needed because changing the order of the two digit positions creates a different displayed code.

Answer: 720 badge codes.

Check your picture

A meal has 4 mains, 3 sides, and 2 drinks. How many complete meals are possible?

Reveal answer

24

This lesson versus the whole chapter

Your topic-specific practical example is above.

The final lesson collects five longer chapter-wide workflows for machine learning, LLMs, trading, physics, and everyday decisions.

Formula shelf

Symbols with meaning

Product rulem stages × n choices = mn

Multiplies choices made in sequence.

Factorialn!=n(n−1)⋯1

Counts arrangements of n distinct objects.

PermutationP(n,r)=n!/(n−r)!

Counts ordered selections without replacement.

CombinationC(n,r)=n!/[r!(n−r)!]

Counts unordered selections.

Multiset arrangementn!/(n₁!⋯nₖ!)

Removes swaps among identical copies.

Circular arrangement(n−1)!

Removes rotations of a round-table seating.

Stars and barsC(n+k−1,k−1)

Distributes n identical items among k distinct boxes.

Pigeonhole principlesome box has at least ⌈N/k⌉ objects

Guarantees crowding when N objects enter k boxes.

Before moving on

You are ready when you can…

  • Choose correctly between addition and multiplication counting rules.
  • Recognize whether order matters and use permutations or combinations.
  • Handle repeated selections, identical objects, and circular symmetry.
  • Count restricted outcomes with cases, complements, and inclusion–exclusion.
  • Model identical-item distributions with stars and bars and prove guaranteed crowding with the pigeonhole principle.