Stirling Numbers Calculator

S(8, 3) - partitions into 3 groups966
Bell number B(8) - all partitions4,140
One fewer group S(8, 2)127
One more group S(8, 4)1,701
How this was calculated
  1. A Stirling number of the second kind, S(n, k), counts the ways to partition a set of n labelled items into exactly k nonempty groups - the grouping is all that matters, not any order.
  2. The recurrence builds each value from the row above: S(n, k) = k x S(n-1, k) + S(n-1, k-1), because a new item either joins one of the k existing groups or starts a group of its own.
  3. For n = 8 and k = 3 the count is S(8, 3) = 966 different partitions.
  4. Adding the whole row gives the Bell number B(8) = 4,140 - every possible partition of 8 items into any number of groups.

The Stirling Numbers Calculator computes Stirling numbers of the second kind, written S(n, k), which count the ways to split n distinct items into exactly k unlabelled groups. Enter your values and the calculator returns the count directly. For example, 8 distinct items split into exactly 3 unlabelled groups can be done in 966 ways, and summed over every possible group count, the Bell number B(8) is 4,140. Splitting 6 items two ways gives S(6, 2) = 31, and three ways gives S(6, 3) = 90. For a larger case, S(10, 4) = 34,105 of the B(10) = 115,975 total partitions of 10 items.

The method behind the result is the standard recurrence S(n, k) = k x S(n-1, k) + S(n-1, k-1), which builds the whole triangle one row at a time: each new item either joins an existing group or starts its own. Because this recurrence is the accepted basis for computing Stirling numbers of the second kind, the calculator's output follows the same logic used throughout combinatorics. This page also shows the formula, step-by-step workings, worked examples and sources, so you can check every number yourself rather than taking a black-box answer on trust.

Worked examples

8 items into 3 groups

(8 · 3)

S(8, 3) - partitions into 3 groups966
Bell number B(8) - all partitions4,140
One fewer group S(8, 2)127
One more group S(8, 4)1,701

10 items into 4 groups

(10 · 4)

S(10, 4) - partitions into 4 groups34,105
Bell number B(10) - all partitions115,975
One fewer group S(10, 3)9,330
One more group S(10, 5)42,525

6 items split two ways

(6 · 2)

S(6, 2) - partitions into 2 groups31
Bell number B(6) - all partitions203
One fewer group S(6, 1)1
One more group S(6, 3)90

How Stirling numbers of the second kind work

Stirling numbers of the second kind answer a very specific counting question: in how many ways can you divide a set of n distinct, labelled items into exactly k groups, where the groups themselves carry no labels and no group may be empty? The order of the groups does not matter, and the order of items inside a group does not matter. What matters is only which items end up together. This is why the word "unlabelled" is central: {A, B} and {C} is the same split as {C} and {A, B}, counted once, not twice. A stirling numbers calculator applies this definition directly, so every result it returns counts genuine partitions rather than ordered arrangements.

A concrete example makes the scale clear. Take 8 distinct items and split them into exactly 3 unlabelled non-empty groups: there are 966 ways to do it, so S(8, 3) = 966. The neighbouring values show how sharply the count moves with the group count. With only 2 groups, S(8, 2) = 127 — far fewer, because forcing everything into two piles is restrictive. With 4 groups, S(8, 4) = 1,701 — noticeably more, because more groups create more ways to distribute the items. The middle value sits between its neighbours, which is typical of the triangle's shape. Summed over every possible group count, the total number of partitions of 8 items is the Bell number B(8) = 4,140.

The same pattern appears at larger sizes. For 10 items, S(10, 4) = 34,105, out of B(10) = 115,975 total partitions of 10 items. That means partitions into exactly four groups account for a substantial share of all partitions of ten items, but by no means all of them — the remaining partitions spread across the other possible group counts. Smaller cases are easy to check by hand: splitting 6 items two ways gives S(6, 2) = 31, and splitting them three ways gives S(6, 3) = 90.

You do not need to enumerate partitions to get these numbers. The recurrence S(n, k) = k x S(n-1, k) + S(n-1, k-1) builds the whole triangle one row at a time. The logic is a single decision about the newest item: it either joins one of the k existing groups — giving k x S(n-1, k) possibilities — or it starts a group of its own, leaving S(n-1, k-1) ways to arrange the rest. Adding those two cases produces every entry from the row above, starting from the base cases at the top of the triangle.

When you use the tool, keep the definition in mind: the result counts groupings, not orderings, and empty groups are never allowed. That is the distinction between Stirling numbers of the second kind and the simpler problem of handing out labelled items to labelled boxes, where the boxes themselves would multiply the count.

S(8, 3) = 966 partitions of 8 items into 3 unlabelled non-empty groups — between S(8, 2) = 127 and S(8, 4) = 1,701.

The recurrence, step by step

The Stirling numbers of the second kind count the ways to split a set of distinct items into a given number of unlabelled groups — groups with no names or order, so only which items sit together matters. The recurrence S(n, k) = k × S(n-1, k) + S(n-1, k-1) builds the whole triangle one row at a time, and it does so by asking a single question about the newest item: where does it go?

Take the nth item and look at the row above, which covers the first n-1 items. If those n-1 items were already arranged into k groups, the new item has k choices — it can join any one of the k existing groups, which accounts for the term k × S(n-1, k). If instead the first n-1 items formed only k-1 groups, the new item must open a group of its own, and there is exactly one way to do that, which accounts for S(n-1, k-1). Those two cases cover every possibility, so adding them gives S(n, k).

The base cases anchor the triangle. A single item forms exactly one group, and no nonempty set can be split into zero groups. From there each row is computed from the row directly above it, with no enumeration of individual partitions. That is why S(10, 4) = 34,105 can be built from the row above instead of being counted by hand — the row for 9 items supplies both ingredients, and a few additions and multiplications produce the answer. The same S(10, 4) = 34,105 is part of the B(10) = 115,975 total partitions of 10 items.

Small cases show the pattern clearly. Splitting 6 items two ways gives S(6, 2) = 31, and three ways gives S(6, 3) = 90. Each of those values, in turn, feeds the row for 7 items. This is also what makes a stirling numbers calculator practical: it can fill the triangle row by row up to whatever n and k you enter, rather than trying to list every grouping.

The two terms have a plain meaning worth keeping in mind. The k × S(n-1, k) term is the "join an existing group" branch, multiplied by the number of groups available to join. The S(n-1, k-1) term is the "start a new group" branch, and it carries no multiplier because there is only one way to begin a fresh group. Summed across every possible group count, these values produce the Bell numbers — for instance, 8 distinct items split into exactly 3 unlabelled groups in 966 ways, and summed over every possible group count, the Bell number B(8) is 4,140.

  • Join branch: the new item enters one of k existing groups — k × S(n-1, k).
  • New-group branch: the new item starts its own group — S(n-1, k-1).
  • Add the branches: S(n, k) = k × S(n-1, k) + S(n-1, k-1).
  • Build upward: each row comes from the row above, so S(10, 4) = 34,105 needs no hand enumeration.
Every entry in the triangle is the sum of two smaller entries from the row above: one scaled by k, one left as is.

Bell numbers: summing the row

A single Stirling number answers one narrow question: in how many ways can n distinct items be split into exactly k unlabelled groups? A Bell number answers the broader question. Add up every Stirling number in row n — every possible group count from 1 to n — and you get the total number of ways to partition those n items into groups of any size at all. That total is the Bell number B(n). A stirling numbers calculator becomes a Bell number calculator the moment you sum the row instead of reading a single entry.

The arithmetic is straightforward once the row exists. For 6 items, splitting them two ways gives S(6, 2) = 31, and splitting them three ways gives S(6, 3) = 90. Those are just two entries in the row; the Bell number for 6 items, B(6), is 203, the sum of all six entries. For 8 items the effect is larger. There are 966 ways to split 8 distinct items into exactly 3 unlabelled groups, but summed over every possible group count, the Bell number B(8) is 4,140. One column of the triangle tells you about one group count; the row total tells you about every partition that exists.

The same relationship holds at larger sizes. Of the B(10) = 115,975 total partitions of 10 items, S(10, 4) = 34,105 are the ones that use exactly four groups. So a single column can account for a substantial share of the row without being the whole story — the remaining partitions spread across one, two, three, five, and up to ten groups.

Bell numbers grow fast, and the growth outruns exponentials: B(6) = 203, B(8) = 4,140 and B(10) = 115,975. Each step up in n multiplies the total by a widening factor, which is why the row sum climbs so much more steeply than the individual Stirling entries along the way. Summing a row is easy arithmetic, but the numbers it produces quickly become large enough that you want the calculator to handle them rather than working the triangle by hand.

There is a practical reason the row is easy to build in the first place. The recurrence S(n, k) = k x S(n-1, k) + S(n-1, k-1) builds the whole triangle one row at a time — each new item either joins an existing group or starts its own. Because every row is generated from the row above it, the full set of values needed for a Bell number arrives together. Sum the row, and you have B(n).

Bell number B(n) = the sum of row n of the Stirling numbers of the second kind. B(6) = 203, B(8) = 4,140, B(10) = 115,975.

Reading your result

When a Stirling numbers calculator returns a value, the number by itself can feel arbitrary. The quickest way to make sense of it is to look at its neighbors in the same row. Take S(10, 3) = 9,330 and S(10, 5) = 42,525. These two values sit on either side of S(10, 4) = 34,105, and together they show the shape of the row: the count climbs as you move from three groups toward the middle, then falls away again as the group count grows. Reading a result against its one-fewer and one-more neighbors tells you whether you are on the rising slope, at the peak, or on the way down.

The peak sits near the middle of the row. For 10 items, S(10, 4) = 34,105 is one of the largest entries, and it accounts for a substantial share of the B(10) = 115,975 total partitions of 10 items. That is not a coincidence of this one row. Splitting 6 items two ways gives S(6, 2) = 31, and splitting them three ways gives S(6, 3) = 90 — the three-group count is roughly triple the two-group count. The middle of each row is where the most arrangements exist, because very few groups force large, rigid clumps while very many groups force mostly singletons. Both extremes leave little room for variety.

The same logic explains smaller cases. Eight distinct items split into exactly 3 unlabelled groups in 966 ways, and summed over every possible group count the Bell number B(8) is 4,140. So the 3-group answer is a slice of a much larger total, not the whole story. When you use a stirling numbers calculator, check which slice you asked for: S(n, k) counts partitions into exactly k groups, while the Bell number adds up every k from 1 to n. A result that looks small next to the Bell number is simply one column of the row.

The triangle itself is built by a simple rule: S(n, k) = k x S(n-1, k) + S(n-1, k-1). Each new item either joins one of the k existing groups or starts a group of its own. That is why neighboring entries are so informative — every value is assembled from the two entries above it, so the row rises and then falls in a smooth, predictable arc. If your result is larger than the entry to its left and smaller than the entry to its right, you are climbing toward the peak; if the reverse is true, you have passed it. Comparing your answer with those two neighbors is usually enough to confirm the calculator picked the right row and column.

S(10, 3) = 9,330 and S(10, 5) = 42,525 bracket S(10, 4) = 34,105 — the row peaks near the middle.

FAQs

What do Stirling numbers of the second kind count?

Stirling numbers of the second kind count the ways to split n distinct items into k non-empty unlabelled groups. For example, there are 966 ways to split 8 items into 3 groups. Each split is a partition: every group holds at least one item, and no group is treated as distinct from another.

What is a Bell number?

A Bell number is the total number of partitions of a set over all group counts, adding up the Stirling numbers for every k. For 8 items, B(8) = 4,140. For 10 items, B(10) = 115,975. So the Bell number gives one total for all possible group counts rather than a count for a single k.

How are Stirling numbers calculated?

They are calculated by the recurrence S(n, k) = k x S(n-1, k) + S(n-1, k-1), building up from S(n, 1) = 1. Each entry combines the prior row, so the table grows row by row. As an example, the 6-item row starts 1, 31, 90.

What is S(10, 4)?

S(10, 4) = 34,105. That is the single largest share of the 115,975 partitions of 10 items, after S(10, 5) = 42,525. So splitting 10 items into 4 groups accounts for more partitions than any other group count except 5 groups.

Why are the groups unlabelled?

The groups are unlabelled because the count is about the grouping itself, not named teams. If the 3 groups were labelled, the 966 ways for 8 items would be multiplied by 6. Treating groups as unlabelled means arrangements that differ only by which group is called first count as one.

Where do Stirling numbers appear?

Stirling numbers appear in counting surjections, in moments of the Poisson distribution, and in the expansion of powers into falling factorials. All of these are built on the same partition counts, such as S(6, 2) = 31. The same numbers that count groupings also drive these formulas.

Sources

Related calculators

Permutations Calculator
Permutations P(n, r), combinations C(n, r), permutations with repetition and n factorial, with large results in compact form.
Multinomial Coefficient Calculator
How many ways N items split into groups of given sizes: N! divided by the product of the group factorials.
Factorial Calculator
Exact factorials up to 170! computed with arbitrary-precision integers — no scientific-notation rounding — with the digit count and trailing zeros (Legendre's formula) explained.