Counting and Combinatorics

Inclusion-Exclusion for Overlapping Events

Learn to avoid double counting when events overlap, with card and dice examples for two sets and a worked three-set case you can verify by hand.

On this page
  1. The double counting trap
  2. The two-event rule
  3. Three events
  4. A card example with three overlapping groups
  5. When to use it, and when not to

The double counting trap

Suppose you draw one card from a standard 52-card deck. What is the chance it is a heart or a face card (jack, queen or king)?

There are 13 hearts and 12 face cards. Adding gives 25. But three of those cards, the jack, queen and king of hearts, belong to both groups and were counted twice. The correct number of cards that are hearts or face cards is

13 + 12 − 3 = 22,

so the probability is 22/52 = 11/26, about 42.3 percent. Adding 25/52 would give about 48.1 percent, which overstates the answer.

This is the central issue: when two events can happen together, simply adding their counts counts the overlap twice. The fix is to subtract it once.

The two-event rule

For two sets A and B:

|A or B| = |A| + |B| − |A and B|.

The same statement holds for probabilities when outcomes are equally likely: P(A or B) = P(A) + P(B) − P(A and B).

When the events cannot occur together, the overlap is zero and the rule collapses to plain addition. Drawing a heart or a spade gives 13 + 13 = 26, since no card is both. Forgetting that the rule needs this check is a typical source of adding probabilities wrongly.

Another example with dice

Roll two six-sided dice. How many of the 36 ordered outcomes show at least one six?

  • First die is a six: 6 outcomes (6 with any second die).
  • Second die is a six: 6 outcomes.
  • Both are sixes: 1 outcome, counted in each of the lists above.

6 + 6 − 1 = 11 outcomes, giving 11/36, about 30.6 percent. You can confirm this with the complement: 25 outcomes have no six (5 × 5), and 36 − 25 = 11. The same check is the logic behind the at least one six calculation.

Three events

With three sets A, B and C, subtracting the pairwise overlaps removes too much: anything in all three sets was added three times, then subtracted three times, so it ends up counted zero times. The triple overlap must be added back:

|A ∪ B ∪ C| = |A| + |B| + |C| − |A∩B| − |A∩C| − |B∩C| + |A∩B∩C|.

Worked example

How many whole numbers from 1 to 100 are divisible by 2, 3 or 5?

  • Divisible by 2: 50
  • Divisible by 3: 33 (since 3 × 33 = 99)
  • Divisible by 5: 20
  • By 2 and 3, that is by 6: 16 (6 × 16 = 96)
  • By 2 and 5, that is by 10: 10
  • By 3 and 5, that is by 15: 6 (15 × 6 = 90)
  • By 2, 3 and 5, that is by 30: 3

50 + 33 + 20 − 16 − 10 − 6 + 3 = 74.

So 74 of the numbers from 1 to 100 qualify, and 26 do not. A short list check supports this: the numbers up to 30 that are divisible by none of 2, 3 or 5 are 1, 7, 11, 13, 17, 19, 23, 29, which is 8 numbers, and 26 over 100 is consistent with that rate.

This number example is not about cards, but it shows the pattern cleanly: alternately add single sets, subtract pairs, add triples, and continue for more sets.

A card example with three overlapping groups

In a single draw from the deck, let A be “the card is a heart”, B “the card is a king” and C “the card is a face card”. Every king is a face card, so the union is just hearts or face cards again, which we already counted as 22 cards. The full three-set formula must agree: 13 + 4 + 12 − 1 (heart and king) − 3 (heart and face card) − 4 (king and face card) + 1 (heart, king and face card, which is the king of hearts) = 22.

When one set sits entirely inside another, as kings sit inside face cards, the formula still works, but you can see the same answer faster by dropping the redundant set. Good practice is to simplify the description of the event first and use the formula only for what genuinely overlaps.

When to use it, and when not to

Inclusion-exclusion is most useful when:

  • You want the chance that at least one of several things happens and they might happen together.
  • Counting the union directly is awkward, but the intersections are easy.

It can be more work than the alternative when the complement is simple. “At least one” is often easier as one minus “none”, which is the idea behind the complement rule. Inclusion-exclusion earns its place in problems like the derangements calculation, where the overlaps have a regular pattern, and the sum of alternating terms is what produces a famous constant.

The rule is a counting identity. It tells you how to count outcomes accurately and has no bearing on whether any particular future draw will go a certain way. Past draws from a fairly shuffled deck do not change the next one, and card games with a built-in house advantage can still cost players money over time. If gambling is causing you difficulty, a local support service can help.

The complete guide to counting and combinatorics

Counting Principles Every Probability Learner Needs
Read the guide

Keep exploring

Guides from other topics

All topics →