Stirling Numbers Calculator
Compute Stirling numbers of the second or unsigned first kind exactly, from their recurrences.
Stirling Numbers Calculator
Compute Stirling numbers of the second or unsigned first kind exactly, from their recurrences.
What the page prints, and what it refuses
Every figure is printed with the rule or formula that produced it, and any numerical tolerance is stated on the result rather than implied. The page refuses an input the formula does not define and names the value it read; it prints no answer it cannot support.
The calculation runs entirely in this browser tab; nothing is uploaded.
Stirling numbers count two different decompositions of a set. The second kind S(n, k) counts partitions of n items into k non-empty blocks; S(6, 3) is 90. The unsigned first kind c(n, k) counts permutations of n items with exactly k cycles; c(5, 3) is 35.
Both are computed from their one-line recurrences with BigInt, so n up to 200 is exact. The page prints which kind it answered and what the number means.
The two recurrences
Second kind: S(n, k) = S(n − 1, k − 1) + k·S(n − 1, k). The new item either forms its own block or joins one of the k existing blocks.
First kind: c(n, k) = c(n − 1, k − 1) + (n − 1)·c(n − 1, k). The new item either starts a new cycle or is inserted after one of the n − 1 existing items. The page keeps one row at a time, so the cost is quadratic in n.
How to use Stirling Numbers Calculator
Enter n and k, choose the kind, then press Run.
The result prints the value, its digit count and a sentence naming what the number counts.
What to Expect
Best for
- Counting set partitions or permutation cycles
- Checking a combinatorics exercise
- Getting an exact value where a table stops
Not ideal for
- Bell numbers, which sum over k and have their own page
- Signed first-kind values
- k above n, which is a different question
What this tool keeps
- n, k and the chosen kind
What may need cleanup
- Nothing: the value is a final integer
Common errors
- k above n is refused
- A fractional n or k is refused by name
Example use cases
- Compute S(6, 3)
- Compute c(5, 3)
- Check a partition count by hand
Sample input
n = 6, k = 3, second kind
Sample output
S(6, 3) = 90
Who this is for
- Combinatorics students
- Readers checking a recurrence
Frequently asked questions
What does S(n, k) count?
The ways to split n distinct items into k non-empty groups where order between groups does not matter. S(4, 2) is 7: three splits of sizes 3+1 and four of sizes 2+2.
What does c(n, k) count?
Permutations of n items with exactly k cycles. c(4, 2) is 11, and the page prints the meaning beside the value so the two kinds are never confused.
Why is the first kind called unsigned?
The signed version alternates sign with n − k. This page prints the count, which is non-negative, and says so.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.