Skip to content
Infinitesimal Dynamics home
Notebook: 0 XP

Discrete Mathematics / Further counting, graphs and algorithms

Inclusion–Exclusion

Count a union by adding, subtracting the overlaps, adding back the triple overlaps, and so on.

3 min read · 1 sections · 1 checks

Contents 2 sections
  1. §1The principle
  2. ?Check yourself

By the end you can

  • Apply inclusion–exclusion to two and three sets
  • Count derangements
  • Count integers coprime to a number

Helps to know: Sets, Relations and Functions, Counting: Permutations and Combinations

§1The principle

∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−∣A∩B∣−∣A∩C∣−∣B∩C∣+∣A∩B∩C∣|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|

Example 1Integers from 1 to 100 divisible by 2, 3 or 5

  1. Singles: 50+33+20=10350 + 33 + 20 = 103.

Check yourself

  1. Q1
    How many integers from 1 to 30 are divisible by 2 or 3?