Understand the subject
What is inclusion–exclusion?
Inclusion–exclusion counts a union by correcting overlap. Adding set totals counts shared members twice, so the shared part is removed once.
Use it for overlapping groups, surveys, tags, memberships, and finite events.
See the structure
The overlap is counted twice before correction
A
20B
15both
520 + 15 − 5 = 30
Worked example
Check the rule with a small case
20 in A, 15 in B, and 5 in both gives 20 + 15 − 5 = 30 in at least one group.
Interpret with care
Choose the right counting model
Intersection sizes must be consistent with the set sizes. For three sets, pairwise intersections and the triple intersection all matter.
Use the Permutation & Combination Generator when a small case needs to be inspected rather than only counted.
Quick guide
How to use this calculator
- Choose two or three sets.
- Enter each set size and every required intersection size.
- Read the size of the union after overlap is corrected.
Calculation method
Subtract duplicate counts and restore triple overlap
For two sets, |A∪B|=|A|+|B|−|A∩B|. With three sets, subtract all pairwise intersections and add the triple intersection once.
Worked example
Two overlapping groups
If 20 people are in A, 15 in B, and 5 in both, 30 are in at least one group.
20+15−5 = 30
Supported inputs
Precision and limits
Discrete domain
Inputs are whole counts. Negative, fractional, grouped, and scientific-notation inputs are rejected.
Exact integers
Results use arbitrary-precision integers and are never rounded. Inputs and output size are bounded to keep the page responsive.
Consistency
Impossible intersection sizes are rejected instead of producing a misleading union.