English
StirlingSecond(n,k) counts the number of ways to partition an n-element set into k nonempty subsets.
Русский
Число Стирлинга второго рода Stirlings(n,k) равно количеству способов разбить множество из n элементов на k непустых подмножеств.
LaTeX
$$$\mathrm{stirlingSecond}(n,k) \text{ counts the partitions of an } n\text{-element set into } k\text{ nonempty subsets.}$$$
Lean4
/-- `Nat.stirlingSecond n k` is the Stirling number of the second kind,
counting the number of ways to partition a set of `n` elements into `k` nonempty subsets.
-/
def stirlingSecond : ℕ → ℕ → ℕ
| 0, 0 => 1
| 0, _ + 1 => 0
| _ + 1, 0 => 0
| n + 1, k + 1 => (k + 1) * stirlingSecond n (k + 1) + stirlingSecond n k