In this context, a partition of $[n]$ is an assignment of each $1\le i\le n$ to a class, but in which the class names don't matter (can be given in any order). For example:
- $[1]$ has one partition, $\{\{1\}\}$.
- $[2]$ has two partitions: $\{\{1,2\}\}, \{\{1\},\{2\}\}$.
- $[3]$ has five partitions: $$\{\{1,2,3\}\}, \{\{1\},\{2,3\}\}, \{\{2\},\{1,3\}\}, \{\{3\},\{1,2\}\}, \{\{1\},\{2\},\{3\}\}.$$
- $[4]$ has 15 partitions: $$\{\{1,2,3,4\}\},$$ $$\{\{1\},\{2,3,4\}\}, \{\{2\},\{1,3,4\}\}, \{\{3\},\{1,2,4\}\}, \{\{4\},\{2,3,4\}\},\\ \{\{1,2\},\{3,4\}\},\{\{1,3\},\{2,4\}\},\{\{1,4\},\{2,3\}\},$$ $$\{\{1\},\{2\},\{3,4\}\},\{\{1\},\{3\},\{2,4\}\},\{\{1\},\{4\},\{2,3\}\},\\ \{\{2\},\{3\},\{1,4\}\},\{\{2\},\{4\},\{1,3\}\},\{\{3\},\{4\},\{1,2\}\},$$ $$\{\{1\},\{2\},\{3\},\{4\}\}.$$
What is an efficient way to enumerate these partitions, and how many are there for general $n$? (I searched OEIS but the four terms here is not enough and I don't have a good algorithm to calculate more terms.)
Edit: To make this question not entirely trivial, is there a way to generate the $k$-th partition of $n$ using the recurrence relation for Bell numbers?
These are the Bell numbers, OEIS A000110. The Bell triangle is a fairly efficient way to generate them, and there’s a great deal more information at the Wikipedia and OEIS links. I’ve not really thought about efficient schemes for enumerating the partitions.