IM
Apr 15, 2026
How to use the inclusion-exclusion principle for counting problems?
I am studying combinatorics and I understand the basic inclusion-exclusion principle for two sets:
But I need help with:
- The general formula for sets
- A concrete example: How many integers from 1 to 100 are divisible by 2, 3, or 5?
- How to handle problems where we want elements that belong to exactly one set (not just at least one)?
I know the general formula involves alternating sums of intersections, but I get confused with the signs.
1 answers210 views
Loading comments...
1 Answer
PM
Prof. Michael TorresApr 15, 2026 Accepted**General Formula (Principle of Inclusion-Exclusion):**
$$\left|\bigcup_{i=1}^{n} A_i\
ight| = \sum_{i} |A_i| - \sum_{i<j} |A_i \cap A_j| + \sum_{i<j<k} |A_i \cap A_j \cap A_k| - \cdots + (-1)^{n+1} |A_1 \cap \cdots \cap A_n|$$
**Example: Numbers 1-100 divisible by 2, 3, or 5.**
Let $A_2, A_3, A_5$ be numbers divisible by 2, 3, 5 respectively.
\begin{align*}
|A_2| &= 50, \quad |A_3| = 33, \quad |A_5| = 20 \\
|A_2 \cap A_3| &= \lfloor 100/6 \
floor = 16 \\
|A_2 \cap A_5| &= \lfloor 100/10 \
floor = 10 \\
|A_3 \cap A_5| &= \lfloor 100/15 \
floor = 6 \\
|A_2 \cap A_3 \cap A_5| &= \lfloor 100/30 \
floor = 3
\end{align*}
$$|A_2 \cup A_3 \cup A_5| = 50 + 33 + 20 - 16 - 10 - 6 + 3 = 74$$
**Elements in exactly one set:**
Use the formula $|\text{exactly one}| = |A| + |B| + |C| - 2(|A \cap B| + |A \cap C| + |B \cap C|) + 3|A \cap B \cap C|$.
For our example: $50 + 33 + 20 - 2(16 + 10 + 6) + 3(3) = 103 - 64 + 9 = 48$ numbers divisible by exactly one of 2, 3, or 5.
Loading comments...