User Rating 0.0
Total Usage 0 times
Range: 0–100
Presets:
Enter a value for n and click Generate to compute Bell numbers.
Is this tool helpful?

Your feedback helps us improve.

About

Bell numbers count the number of ways to partition a set of n elements into non-empty subsets. B(0) = 1 by convention. B(3) = 5 because the set {1, 2, 3} has exactly five partitions. Growth is super-exponential: B(15) = 1,382,958,545 already exceeds 109, and B(25) surpasses 1018, overflowing standard 64-bit integers. This generator uses the Bell triangle (Aitken’s array) with arbitrary-precision BigInt arithmetic, so every digit is exact through B(100) and beyond. Miscounting partitions propagates errors in combinatorial optimization, database query planning, and Bayesian network structure enumeration.

The tool also renders the full Bell triangle so you can trace how each value derives from its neighbors. Note: computation is exact but display of B(100) - a 116-digit number - may wrap on narrow screens. Pro tip: Bell numbers satisfy Dobinski’s formula and appear in moment calculations of the Poisson distribution with λ = 1.

bell numbers combinatorics sequence generator bell triangle set partitions integer sequences

Formulas

Bell numbers are computed via the Bell triangle (also called Aitken’s array or the Peirce triangle). Construct a triangular array where each row yields the next Bell number.

a0,0 = 1

an,0 = an1,n1

an,k = an,k1 + an1,k1

B(n) = an,0

Where an,k is the element at row n, column k of the Bell triangle. The Bell number B(n) is the first element of row n.

An equivalent closed-form is Dobinski’s formula:

B(n) = 1e k=0 knk!

Where e is Euler’s number (2.71828...). This formula converges but is impractical for exact integer computation. The Bell triangle method is preferred for its O(n2) time complexity and exact BigInt results.

The recurrence relation connecting consecutive Bell numbers uses Stirling numbers of the second kind S(n,k):

B(n) = nk=0 S(n, k)

Where S(n, k) counts partitions of n elements into exactly k non-empty subsets.

Reference Data

nB(n)DigitsContext
011Empty set: one trivial partition
111Singleton set
221{1,2} or {1},{2}
351Five partitions of a 3-element set
4152Equivalent to OEIS A000110(4)
5522Used in Faa di Bruno’s formula
62033Number of rhyme schemes for 6 lines
78773Equivalence relations on 7 elements
84,1404Surjection count related
921,1475Database join orderings
10115,9756Exceeds 105
151,382,958,54510Exceeds 32-bit integer max
2051,724,158,235,37214Requires 64-bit integer
254,638,590,332,229...19Overflows uint64
308.46 × 102324Requires BigInt / arbitrary precision
401.58 × 103536Combinatorial explosion regime
501.86 × 104748Practical enumeration impossible
609.76 × 105960Astrophysical-scale count
701.66 × 107374Exceeds atoms in observable universe
808.58 × 108687Cryptographic-scale magnitude
901.28 × 10101102Googol surpassed
1004.76 × 10115116Maximum in this tool

Frequently Asked Questions

Bell numbers grow at a super-exponential rate, roughly B(n) ~ (n / (W(n)))^n where W is the Lambert W function. B(15) already exceeds 10^9 (32-bit signed max is ~2.1 × 10^9), and B(23) = 4,638,590,332,229 exceeds the 53-bit safe integer limit in JavaScript's Number type. This tool uses BigInt arithmetic to maintain exact precision through B(100), which has 116 digits.
Both are triangular arrays built by summing adjacent elements, but with different initialization and rules. Pascal's triangle uses binomial coefficients with C(n,k) = C(n-1,k-1) + C(n-1,k), while the Bell triangle wraps: each row's first element equals the previous row's last element. The diagonal sums of Pascal's triangle give Fibonacci numbers; the left edge of the Bell triangle gives Bell numbers.
The Bell triangle method requires O(n²) BigInt additions and O(n²) storage for the full triangle. Each BigInt addition for large n involves operands with O(n·log(n)) digits, so the true arithmetic cost is O(n³·log(n)). For n = 100, this completes in under 10 milliseconds in modern browsers. Memory is dominated by storing the triangle: roughly n²/2 BigInt values.
Yes. The Touchard congruence states B(p + n) ≡ B(n) + B(n + 1) (mod p) for any prime p. This periodicity modulo primes makes Bell numbers useful in algebraic combinatorics and finite field enumeration. The Bell triangle method works with modular arithmetic by replacing BigInt with standard integers mod p.
Bell numbers appear in database query optimization (counting join orderings), compiler design (register allocation partitions), Bayesian network structure enumeration, rhyme scheme counting in computational linguistics, and statistical mechanics (cluster expansions). In machine learning, B(n) counts the possible clusterings of n data points, which bounds the search space of non-parametric clustering algorithms.
BigInt values are converted to strings and formatted with locale-appropriate thousand separators for readability. On narrow screens, long numbers wrap naturally with CSS word-break rules. The copy function exports raw unformatted integers suitable for pasting into CAS software like Mathematica or SageMath. Print layout uses monospace font at reduced size to fit values on A4 paper.