Bell Number Calculator

Enter a set size n (0–25) to compute the Bell number Bn.

How it is calculated

The tool builds the Bell triangle. Row 0 is 1. Each new row starts with the last number of the row above, and every further entry is the entry to its left plus the entry above that one: a(i,j) = a(i,j-1) + a(i-1,j-1). The first number of row n is the Bell number Bn, the count of ways to split n distinct items into non-empty, unlabelled groups. Here n is a whole number from 0 to 25; a decimal is rounded down (7.9 is treated as 7), and values below 0 or above 25 give no result. Up to 25 the answer fits an exact integer, so no rounding error creeps in. The tool also shows Bn-1, the previous Bell number; for n = 0 it shows 1.

Worked example

Take n = 10. Early rows are 1; 1 2; 2 3 5; 5 7 10 15; 15 20 27 37 52. Carrying on the same way, row 9 starts with 21,147 (B9) and ends with 115,975, so row 10 begins with 115,975, and that first value is the answer. Result: B10 = 115,975 ways to partition a 10-element set, and the previous Bell number B9 is 21,147. The ratio is about 5.5, which shows how fast the sequence grows.

Try this example →

Common mistakes

  • Confusing Bell numbers with Stirling numbers of the second kind: a Stirling number counts partitions into exactly k groups, while Bn adds them up over every k from 1 to n.
  • Treating the elements as identical. Bell numbers count partitions of distinct items; identical items would be a different count.
  • Expecting groups to be labelled or ordered. Swapping two groups, or the order inside a group, is not a new partition.
  • Entering n = 26 or more, or a negative number, and expecting a value: the tool accepts only 0 to 25.
  • Entering a decimal like 7.9 and reading the result as B8; it is rounded down to 7, giving 877.

About this calculator

The Bell number Bn counts the total number of ways to partition a set of n distinct elements into non-empty, unlabeled subsets — every possible way of grouping the elements, regardless of order between or within groups. Bell numbers grow explosively (B0=1, B1=1, B2=2, B3=5, B4=15, B5=52...) and are most efficiently computed with the Bell triangle, a Pascal's-triangle-like construction where each row's first entry is the last entry of the previous row, and this calculator builds that triangle to compute Bn exactly for n up to 25.

Bell numbers are a foundational object in combinatorics and set theory courses, appearing whenever a problem asks “in how many ways can this set be grouped” — from counting equivalence relations on a set to enumerating rhyme schemes in poetry (a genuinely used application) and analyzing partition lattices in abstract algebra. They also show up in computer science when counting the number of ways to partition data into clusters without predetermined cluster labels.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Bell numbers are a good reality check before you try to brute-force a grouping problem. Trying every way to cluster 12 items means checking 4,213,597 partitions, which a computer handles easily; with 15 items it is 1,382,958,545, and with 20 items it passes 51 trillion. That jump is why exhaustive clustering search stops being practical so quickly. What problem are you counting partitions for: clustering, scheduling, or a puzzle?

Popular calculators

All Calculators