What is the Subset Calculator?
A subset is any selection of elements taken from a larger set, including the empty set and the set itself. This calculator answers two common combinatorics questions: how many subsets does a set of n elements have in total, and how many of those subsets contain exactly k elements. It is useful for students learning set theory, probability, and discrete mathematics, as well as anyone counting possible combinations.
How to use it
Enter the size of your set as n (the number of distinct elements). The calculator immediately returns the total number of subsets, equal to \(2^n\), and the number of proper/non-empty subsets, \(2^n - 1\). Optionally enter a subset size k to also get the number of subsets containing exactly k elements, computed with the binomial coefficient \(C(n, k)\). Leave k blank if you only need the total.
The formula explained
Each element of the set can independently be included or excluded from a subset — that's 2 choices per element. With n independent elements the total count is $$2 \times 2 \times \dots \times 2 = 2^n$$ To count subsets of a fixed size k, we use the combination formula $$C(n, k) = \frac{n!}{k!\,(n - k)!}$$ which selects k elements without regard to order. Summing \(C(n, k)\) over all k from 0 to n recovers \(2^n\).
Worked example
Suppose n = 5. The total number of subsets is \(2^5 = 32\), and the number of non-empty subsets is 31. The number of 2-element subsets is $$C(5, 2) = \frac{5!}{2! \cdot 3!} = \frac{120}{2 \cdot 6} = 10$$ So from a 5-element set there are exactly 10 possible pairs.
FAQ
Does the total include the empty set? Yes. The \(2^n\) count includes both the empty set and the full set. Subtract 1 for non-empty subsets, or 2 for proper non-empty subsets.
What if k is larger than n? There are no such subsets, so \(C(n, k) = 0\) whenever \(k > n\) or \(k < 0\).
Why is the max around 170? \(2^n\) and factorials grow extremely fast; beyond roughly n = 170 the values exceed the range that standard floating-point numbers can represent.