What fraction of integers will be divisible by 3, by 7, or by both?
My thought process was that the fraction would be given by 1/3 + 1/7. However, a solution that I found online claims that the correct fraction is given by 1/3 + 1/7 - 1/21. I suspect that the stipulation "or both" has something to do with the discrepancy, but I'm not sure how exactly. Can someone help me to understand which approach is correct?
If $A$ is the event that a random integer is divisible by $3$, and $B$ is the event that it is divisible by $7$:
$$ P(A\cup B)= P(A) + P(B) - P(A\cap B) = \frac{1}{3}+\frac{1}{7}-\left(\frac{1}{3}*\frac{1}{7}\right)=\frac{1}{3}+\frac{1}{7}-\frac{1}{21} $$
Without subtracting $\frac{1}{21}$, numbers such as $21$, $42$, etc are counted twice.
See: https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle