Set Partitions & Stirling Numbers Calculator
Count the ways to partition n objects into k groups (Stirling numbers of the second kind) and into any number of groups (Bell number).
By CalcLumen · Reviewed by Igor Zagorodnyi · Updated · How we check our math
Pre-filled with an example — change any number to calculate your own.
This calculator counts the ways to split a set of distinct objects into groups. Enter the number of objects (n) and the number of groups (k), and it returns the Stirling number of the second kind S(n, k) — the number of ways to partition the objects into k non-empty, unlabeled groups — plus the count for labeled groups and the Bell number for any number of groups.
For example, the number of ways to sort 11 different books into 4 identical packets is S(11, 4) = 145,750. If the 4 packets are distinguishable (packet A, B, C, D), each way is counted k! times, giving 4! × 145,750 = 3,498,000. Allowing any number of packets from 1 to 11 gives the Bell number B(11) = 678,570.
Often used alongside this tool: average calculator, standard deviation calculator and cagr calculator.
How to use the Set Partitions & Stirling Numbers Calculator
- 1Enter n — the number of distinct objects to divide up.
- 2Enter k — how many groups you want to split them into.
- 3Read S(n, k) for identical (unlabeled) groups.
- 4Use the labeled result if the groups are distinguishable, or the Bell number for any number of groups.
Set partitions questions, answered
What is a Stirling number of the second kind?+
S(n, k) is the number of ways to partition a set of n distinct objects into exactly k non-empty subsets, where the subsets themselves are not labeled or ordered. It satisfies the recurrence S(n, k) = k · S(n−1, k) + S(n−1, k−1), with S(n, n) = 1 and S(n, 0) = 0 for n ≥ 1.
What's the difference between identical and labeled groups?+
If the groups are interchangeable (e.g. identical boxes), use S(n, k). If the groups are distinguishable (e.g. numbered boxes, or people receiving them), multiply by k!, because each partition can be assigned to the labeled groups in k! ways. That labeled count, k!·S(n, k), also equals the number of ways to map n objects onto k groups so that none is empty (surjections).
What is the Bell number?+
The Bell number B(n) is the total number of ways to partition n objects into any number of non-empty groups, from 1 up to n. It is the sum of S(n, k) over all k, so B(n) = S(n, 1) + S(n, 2) + … + S(n, n).
How is this different from combinations (nCr)?+
Combinations count how many ways to choose r items from n, ignoring order — a single subset. Set partitions count how many ways to split the whole set into several non-empty groups at once. For choosing items, use the permutations and combinations calculator instead.
Related calculators
Find X% of a number, what percent one number is of another, and the percentage increase or decrease between two values, with the formula shown for each.
Calculate your grade point average from your course grades and credit hours on the standard 4.0 scale, with your total quality points.
Find your weighted course grade from assignment scores and weights, or the score you need on the final to hit your target.
Add, subtract, multiply and divide fractions and mixed numbers, with the result simplified to lowest terms, shown as a decimal and worked step by step.