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

  1. Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
  2. Enter n, k according to the field table, then run the tool.
  3. Read value. Preserve exact decimal strings and the stated indexing or coefficient order.
  4. Keep exact decimal strings for subsequent integer arithmetic; distinguish them from any explicitly approximate numeric result.
Input fieldMeaningValue type and boundsRequirement
nElement count (resource limit 300)integer; minimum 0; maximum 300Required
kBlock count (resource limit 300)integer; minimum 0; maximum 300Required

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 fieldMeaningValue type
valueStirling number of the second kindstring (integer/arbitrary)
json
{
  "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

  1. 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.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies