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).

Into 4 identical groups — S(n,k)
145,750
Into 4 labeled groups — k!·S(n,k)
3,498,000
Into any number of groups — Bell(n)
678,570
Groups must be non-empty
each group ≥ 1
TThe Crypto Tools69+ free crypto calculators — profit, fees, DCA and more.Our networkVisit →

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.

How to use it

  1. 1Enter n — the number of distinct objects to divide up.
  2. 2Enter k — how many groups you want to split them into.
  3. 3Read S(n, k) for identical (unlabeled) groups.
  4. 4Use the labeled result if the groups are distinguishable, or the Bell number for any number of groups.

Frequently asked questions

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