Bell Number Calculator
Calculate Bell numbers, which count the number of ways to partition a set.
Calculate B_n
B_5
52
Number of ways to partition a set of 5 elements
Bell Sequence
Stirling Decomposition of B_5
B_5 = Σ S(5, k) for k = 0 to 5
Bell Triangle
Each row starts with the last element of the previous row. B_n is the first element of row n.
Formulas
Stirling Sum
B_n = Σ S(n,k) for k=0 to n
Recurrence
B_{n+1} = Σ C(n,k)×B_k
Dobinski's Formula
B_n = (1/e) × Σ k^n/k!
Exponential GF
Σ B_n×x^n/n! = e^(e^x-1)
What Are Bell Numbers?
Bell numbers (Bₙ) count the number of ways to partition a set with n labeled elements into non-empty, unlabeled subsets. For example, a 3-element set {a, b, c} can be partitioned in 5 ways: {a}{b}{c}, {a,b}{c}, {a,c}{b}, {b,c}{a}, and {a,b,c} — so B₃ = 5. The sequence begins B₀=1, B₁=1, B₂=2, B₃=5, B₄=15, B₅=52, and grows super-exponentially. This calculator computes Bₙ for any n between 0 and 20 using the efficient Bell triangle method.
Bell numbers appear throughout combinatorics — from counting rhyme schemes in poetry to analyzing equivalence relations and database partitioning strategies. The calculator also displays the underlying Bell triangle (also called the Aitken array or Peirce triangle) and the corresponding Stirling numbers of the second kind S(n,k) for the chosen n, showing how many partitions have exactly k blocks.
Bell Number Formula
Bell numbers can be computed via the Bell triangle, where the first entry of each row equals the last entry of the previous row, and each subsequent entry is the sum of the entry above and the entry to the left.
Bell Triangle Construction
Where:
- B_n= The nth Bell number — counts set partitions of an n-element set
- S(n,k)= Stirling numbers of the second kind — count partitions of n elements into exactly k non-empty subsets. B_n = Σ S(n,k)
Understanding the Results
| Output | Description |
|---|---|
| B_n | The Bell number for the given n — total number of set partitions |
| Bell Sequence | The first numTerms Bell numbers, showing the rapid growth of the sequence |
| Bell Triangle | The first rows of the Bell triangle — the leftmost column gives Bell numbers |
| Stirling Numbers | S(n,k) for all k from 0 to n showing the distribution of partition sizes |
How to Use This Calculator
- Enter n: Choose a value from 0 to 20. The calculator computes B_n and all Stirling numbers S(n,k).
- Set sequence length: Control how many Bell numbers are displayed in the sequence view — useful for seeing the growth pattern.
- Read the results: The Bell triangle visualizes the construction; Stirling numbers show how partitions break down by number of blocks.
Real-World Applications
Bell numbers model set partitioning in combinatorics and computer science. Database sharding strategies that split records across servers correspond to set partitions. In machine learning, clustering algorithms partition data points into groups — the number of possible clusterings of n labeled items is B_n. In natural language processing, the number of ways to group words into phrases follows Bell number patterns.
In probability theory, the moments of the Poisson distribution are Bell numbers: the nth moment of a Poisson(1) distribution equals B_n. In chemistry, Bell numbers count the number of ways to arrange bonds in certain molecular structures. In poetry analysis, the number of possible rhyme schemes for a stanza of n lines is B_n.
Worked Examples
Bell Number for n=3
Problem:
Find B₃ and list all partitions of {a, b, c}.
Solution Steps:
- 1Enter n=3.
- 2Bell triangle: Row 0=[1], Row 1=[1,2], Row 2=[2,3,5], Row 3=[5,7,10,15]. B₃ = 5.
- 3S(3,1)=1 ({abc}), S(3,2)=3 ({a,bc},{b,ac},{c,ab}), S(3,3)=1 ({a},{b},{c}).
Result:
B₃ = 5. The 5 partitions are: {{a,b,c}} (1 block), {{a},{b,c}} {{b},{a,c}} {{c},{a,b}} (2 blocks each), and {{a},{b},{c}} (3 blocks).
Bell Number Growth
Problem:
Observe how quickly Bell numbers grow from n=0 to n=10.
Solution Steps:
- 1Set numTerms=12.
- 2Sequence: B₀=1, B₁=1, B₂=2, B₃=5, B₄=15, B₅=52, B₆=203, B₇=877, B₈=4140, B₉=21147, B₁₀=115975.
Result:
B₁₀ = 115,975 — over 100,000 ways to partition just 10 items. The growth is super-exponential.
Tips & Best Practices
- ✓Bell numbers for n > 20 exceed JavaScript's safe integer range — the calculator uses floating point for display.
- ✓The Bell triangle shows you each step of the construction — follow row by row to understand the recurrence.
- ✓Stirling numbers S(n,k) satisfy S(n,k) = k × S(n−1,k) + S(n−1,k−1) — this recurrence builds the triangle.
- ✓For n=0, B₀=1 because there's exactly one way to partition the empty set: with zero blocks.
- ✓The sequence grows approximately like n! / (log n)^{n} — super-exponentially fast.
Frequently Asked Questions
Sources & References
Last updated: 2026-06-06
Help us improve!
How would you rate the Bell Number Calculator?
Editorial Note
MyCalcBuddy Editorial Team
This page is maintained as an educational calculator reference.
Formula Source: Handbook of Mathematical Functions
by Abramowitz & Stegun