Counting, Permutations & Combinations

Inclusion–Exclusion Calculator

Find the cardinality of the union of two or three overlapping finite sets.

Counting & Combinatorics

Count the union of overlapping sets

Two or three finite sets
  1. 1EnterProvide the known values
  2. 2CalculateResults update automatically
  3. 3VerifyReview the details and units
Try an example

Elements in the union

Enter valid values to see the result.

Your entries are calculated in this browser and are not submitted to 365CALCS.COM.

Feedback

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.

The relationship

The counting rule

See the structure

The overlap is counted twice before correction

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

  1. Choose two or three sets.
  2. Enter each set size and every required intersection size.
  3. 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.