# stirlingS2() Function & Examples

Use the stirlingS2() combinatorics function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## stirlingS2

#### stirlingS2(n, k)

Try it yourself:

```calculio
stirlingS2(5, 3)
```

[bernoulli](https://calcul.io/function/bernoulli/index.md)

---

## stirlingS2(): Stirling Numbers of the Second Kind

**stirlingS2(n, k)** counts ways to partition n labeled items into k nonempty unlabeled groups. It is a core combinatorics function used in grouping and recurrence problems.

## Valid parameters

n and k should be nonnegative integers, with k no larger than n for ordinary nonzero cases. For example, stirlingS2(3, 2) is 3. Use [bellNumbers()](https://calcul.io/function/bellNumbers/index.md) to count partitions across all possible group counts.

Compare with [combinations()](https://calcul.io/function/combinations/index.md) and [permutations()](https://calcul.io/function/permutations/index.md): those select or order items, while Stirling numbers partition every item. Values grow quickly, so retain exact integer arithmetic where possible.

[All functions](https://calcul.io/functions/index.md)
