Stirling Number of the Second Kind
Count partitions of n labeled elements into k nonempty unlabeled blocks exactly, returning zero when k exceeds n; indices are capped at 300.
Description
Stirling numbers of the second kind count ways to divide labeled elements into nonempty unlabeled blocks.
Stirling numbers of the second kind count ways to divide labeled elements into nonempty unlabeled blocks. Permuting block order does not create a new partition.1
The tool returns value. The indexing and output conventions below determine how to read these values.
When to use Stirling Number of the Second Kind
Use this for the following task: Count partitions of n labeled elements into k nonempty unlabeled blocks exactly, returning zero when k exceeds n; indices are capped at 300. Use the input and output conventions below to reproduce the intended mathematical quantity.
How to use Stirling Number of the Second Kind and understand its results
- Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
- Enter n, k according to the field table, then run the tool.
- Read value. Preserve exact decimal strings and the stated indexing or coefficient order.
- Keep exact decimal strings for subsequent integer arithmetic; distinguish them from any explicitly approximate numeric result.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| n | Element count (resource limit 300) | integer; minimum 0; maximum 300 | Required |
| k | Block count (resource limit 300) | integer; minimum 0; maximum 300 | Required |
Use a descending one-row BigInt dynamic program so each update reads the preceding row. Return zero when k exceeds n.
S(n,k)=S(n−1,k−1)+k×S(n−1,k); S(0,0)=1 The symbols and boundary conditions refer to the supplied fields and the implementation described above.
| Output field | Meaning | Value type |
|---|---|---|
| value | Stirling number of the second kind | string (integer/arbitrary) |
{
"input": {
"n": 5,
"k": 3
},
"output": {
"value": "25"
}
} Limitations and assumptions
Both indexes are at most 300. The tool returns a count without enumerating partitions; empty-set and zero-block cases follow the stated recurrence.
Use the declared integer bounds and string formats. Large exact outputs remain decimal strings; numerical approximations use ordinary floating-point arithmetic. A rejected input is different from a valid zero count or false membership flag.
Alternative or Complementary methods
Choose Signed Stirling Number of the First Kind when you need its operation: Return s(n,k), the cycle-count Stirling number multiplied by (−1)^(n−k), exactly as a decimal integer, with s(0,0)=1 and indices capped at 300. Choose Bell Number for the complementary operation: Count partitions of an n-element labeled set as an exact decimal integer; n is capped at 300 for bounded computation.
Background reference: Digital Library of Mathematical Functions, §26.8.
References
-
Digital Library of Mathematical Functions, §26.8 — National Institute of Standards and Technology
Similar or alternative tools
- Signed Stirling Number of the First Kind
Return s(n,k), the cycle-count Stirling number multiplied by (−1)^(n−k), exactly as a decimal integer, with s(0,0)=1 and indices capped at 300.
- Bell Number
Count partitions of an n-element labeled set as an exact decimal integer; n is capped at 300 for bounded computation.