Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

How to Use Inclusion-Exclusion for Two Sets

Adding the sizes of two overlapping groups counts the overlap twice. Inclusion-exclusion adds both sizes and subtracts the overlap once, so every item in either group is counted exactly once.

Recognize the task

The question asks for the items with property A or property B (or both), and the two groups overlap: students taking French or Spanish, numbers divisible by 44 or 66, line-ups where Ann is first or Bo is last. Test: can one item be in both groups? If yes, plain adding double counts it.
The two-set formula is introduced in the inclusion-exclusion lesson.

Two ways to do it

Add, then subtract the overlapusual
∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A \cup B| = |A| + |B| - |A \cap B|
Neither of the twocomplement
∣U∣−∣A∪B∣|U| - |A \cup B|
For "neither", subtract the union from the total (complementary form).

Steps

StepOn the integers 1 to 60 divisible by 4 or 6
1Define the two sets. Name each property as a set of items.AA: multiples of 44; BB: multiples of 66
2Count each set. Here the count is ⌊60d⌋\left\lfloor \frac{60}{d} \right\rfloor for the multiples of dd.∣A∣=15|A| = 15, ∣B∣=10|B| = 10
3Count the overlap. Items in both sets; for divisibility, the multiples of the least common multiple, 1212.∣A∩B∣=5|A \cap B| = 5
4Add, then subtract the overlap once. Each item in both sets was counted twice by the sum.15+10−5=2015 + 10 - 5 = 20

Worked examples

Example 1 · a survey

neither
4040 students: 2525 soccer, 1818 basketball, 1010 both
how many like neither?
25+18−10=3325 + 18 - 10 = 33
like at least one
40−33=740 - 33 = 7
subtract from the total

Example 2 · divisibility

numbers
11 to 100100: 3333 multiples of 33, 1414 of 77
count each set
both: multiples of 2121, 44 of them
least common multiple
33+14−4=4333 + 14 - 4 = 43

Example 3 · line-ups

arrangements
55 people in a row, Ann first or Bo last
two overlapping conditions
Ann first: 4!=244! = 24; Bo last: 4!=244! = 24
fix one place each
both: 3!=63! = 6
fix both places
24+24−6=4224 + 24 - 6 = 42

See it happen

Draw two overlapping circles. Adding ∣A∣|A| and ∣B∣|B| covers every region, but the lens where the circles overlap is covered twice. Subtracting ∣A∩B∣|A \cap B| once leaves every item counted exactly once. When the circles do not overlap, the formula becomes the plain addition principle. Try it in the two-set Venn diagram tool.

Common mistakes

Adding without the overlap

✗ multiples of 44 or 66 up to 6060: 15+10=2515 + 10 = 25
✓ the 55 multiples of 1212 were counted twice: 25−5=2025 - 5 = 20

Subtracting the overlap twice

✗ 25+18−10−10=2325 + 18 - 10 - 10 = 23 like soccer or basketball
✓ subtract once: 3333; the 2323 is the number who like exactly one

Using the product for the overlap

✗ multiples of 44 and 66 = multiples of 2424: 22 of them
✓ use the least common multiple 1212: 55 of them