Bell Number Calculator

Calculate the nth Bell number or generate a sequence of Bell numbers. Explore the Bell triangle, recurrence relation, examples, and the role of Bell numbers in counting set partitions.

Calculate Bell Numbers

Choose a calculation mode, enter your input, and click Calculate. Your result will appear below the heading without leaving this page.

Used in single-number mode. Enter a whole number from 0 to 100.
Used in sequence mode. Enter 1 to 51 to generate B0 onward.
Reset

What Is a Bell Number?

A Bell number Bn counts the number of ways to partition a set containing n distinct elements into nonempty, disjoint subsets. Each subset is called a block, and the order of the blocks does not matter.

For example, a set with three elements has five possible partitions. Therefore, B3 = 5.

B0, B1, B2, ...
1, 1, 2, 5, 15, 52, 203, 877, 4140, ...

The convention B0 = 1 represents the single partition of the empty set: the empty collection of blocks.

Bell Number Recurrence Formula

Bell numbers can be calculated using the recurrence relation:

B0 = 1
Bn+1 = ∑k=0n ( n choose k ) Bk

The binomial coefficient counts the ways to choose elements for a block, while the Bell number counts partitions of the remaining elements. Summing across the possible choices gives the next Bell number.

Bell numbers and Stirling numbers

Bn = ∑k=0n S(n,k)

Here, S(n,k) is a Stirling number of the second kind. It counts partitions of an n-element set into exactly k nonempty blocks. Adding these counts over all possible block counts gives the Bell number.

How the Bell Triangle Works

The Bell triangle is a convenient way to generate the sequence using addition alone. Start with a row containing 1. Each new row begins with the last entry of the previous row. Every subsequent entry is the sum of the entry immediately to its left and the entry above-left in the previous row.

Row Bell triangle entries Bell number
0 1 B0 = 1
1 1, 2 B1 = 1
2 2, 3, 5 B2 = 2
3 5, 7, 10, 15 B3 = 5
4 15, 20, 27, 37, 52 B4 = 15

The first entry in each row is the corresponding Bell number. This calculator builds the triangle internally and uses exact decimal-string addition, avoiding dependence on large native PHP integers.

Example: Calculate B3

Begin with the initial row:

Row 0: 1

The next row starts with the previous row's last number:

Row 1: 1, 1 + 1 = 2
Row 1: 1, 2

Repeat the rule to obtain the next row:

Row 2: 2, 2 + 1 = 3, 3 + 2 = 5
Row 2: 2, 3, 5

The first entry in row 3 is 5, so the Bell number for a set of three elements is B3 = 5.

First 11 Bell Numbers

n Bell number Bn
0 1
1 1
2 2
3 5
4 15
5 52
6 203
7 877
8 4140
9 21147
10 115975

Applications of Bell Numbers

Frequently Asked Questions

What is the first Bell number?

The first Bell number under the usual zero-based indexing is B0 = 1. The next is B1 = 1.

What does a Bell number count?

Bn counts the number of ways to partition a set of n distinct elements into nonempty, disjoint subsets.

How is a Bell number calculated?

Bell numbers can be calculated using a recurrence involving binomial coefficients or by constructing the Bell triangle. This page uses the Bell triangle.

Can this calculator handle large Bell numbers?

The calculator accepts n up to 100 and uses decimal-string addition to preserve exact results without requiring BCMath or GMP.

Does the calculator require a database or JavaScript?

No. The calculation runs in PHP on the server. It requires no database, third-party package, or JavaScript for form submission.