← All tools

Bell Numbers

The Bell number B(n) is the number of ways to partition a set of n elements — the sequence 1, 1, 2, 5, 15, 52, 203, 877, 4140, …. This tool computes B(n) exactly with big integers by building the Bell (Aitken) triangle, displays that triangle, and shows the row of Stirling numbers of the second kind S(n, k) — the number of partitions into exactly k blocks — whose sum is B(n). Runs locally in your browser.

Input

n =

Result

Bell (Aitken) triangle

Stirling numbers of the second kind S(n, k)

B(n) counts the partitions of a set of n labelled elements (B(0) = 1 by convention; B(3) = 5: {{1,2,3}}, {{1,2},{3}}, {{1,3},{2}}, {{2,3},{1}}, {{1},{2},{3}}). It is computed from the Aitken array: start the triangle with [1]; each new row begins with the last entry of the previous row, and every following entry is the sum of the entry to its left and the entry above-left. The first entry of row n is B(n), and the last entry of row n is B(n+1). S(n, k) — the Stirling number of the second kind — counts partitions into exactly k non-empty blocks, with the recurrence S(n, k) = k·S(n−1, k) + S(n−1, k−1), and B(n) = Σₖ S(n, k). The triangle is capped at small n for readability. Pairs with the Catalan, Derangements, and Integer Partitions tools. Everything runs locally — nothing leaves your browser.