Maths WorkshopMaths problems with full solutions
Exercise 2113Number theory › CongruencesM1Added 3 Nov 2026

Stirling numbers via modular arithmetic

#Stirling#modular arithmetic#combinatorics

Statement

Compute the Stirling number {nk}\left\{{n\atop k}\right\} of the second kind for small nn and verify the recursion {nk}={n−1k−1}+k{n−1k}\left\{{n\atop k}\right\}=\left\{{n-1\atop k-1}\right\}+k\left\{{n-1\atop k}\right\}.

Hint

{nk}\left\{{n\atop k}\right\} counts partitions of {1,…,n}\{1,\ldots,n\} into kk nonempty subsets.

Show solutionHide solution

Solution

Base cases. {n1}=1\left\{{n\atop 1}\right\}=1, {nn}=1\left\{{n\atop n}\right\}=1, {nk}=0\left\{{n\atop k}\right\}=0 if k>nk>n or k=0k=0 (for n>0n>0).

Recursion. Partition the set {1,…,n}\{1,\ldots,n\} into kk blocks. If element nn is alone: {n−1k−1}\left\{{n-1\atop k-1}\right\} ways. Otherwise, nn joins one of the kk blocks of a partition of the first n−1n-1 elements into kk blocks: k⋅{n−1k}k\cdot\left\{{n-1\atop k}\right\} ways.

Values.
- {32}=3\left\{{3\atop 2}\right\}=3
- {42}=7\left\{{4\atop 2}\right\}=7
- {43}=6\left\{{4\atop 3}\right\}=6

Conclusion. The recursion holds.