Calculators

Stirling Number Calculator

Calculate exact Stirling numbers of the second kind for up to 200 distinct items and groups privately in your browser.

Count partitions of distinct items into exactly k nonempty, unlabeled groups. Exact BigInt arithmetic keeps every digit. Your data stays in your browser.

Enter a whole number from 0 to 200 using digits only. S(0, 0) is 1. Five items split into two groups have 15 partitions. More groups than items gives zero.

Your Stirling number will appear here.

Partition distinct items into a fixed number of groups.

The Stirling number of the second kind S(n, k) counts partitions of n distinct items into exactly k nonempty, unlabeled groups. Group order and item order do not matter. For three items A, B and C split into two groups, the three partitions are {AB}{C}, {AC}{B} and {BC}{A}. The recurrence is S(n, k) = k × S(n − 1, k) + S(n − 1, k − 1): the last item either joins one of k existing groups or forms a new group. Starting values are S(0, 0) = 1 and S(n, 0) = 0 for positive n. If k exceeds n the result is zero. For example, S(5, 2) = 15. Summing S(n, k) over all k gives the Bell number B(n). This calculator does not count labeled groups, permutations, first-kind Stirling numbers or partitions of indistinguishable items. Both inputs accept 0 to 200 using one to three digits; leading zeros and surrounding whitespace are accepted, while signs, decimals, separators and scientific notation are rejected. Browser BigInt arithmetic preserves every digit, with zero displayed as one digit. Your inputs are not uploaded or stored.

Frequently Asked Questions

Everything you need to know about this tool, how it works, and privacy.

What does S(n, k) count?

It counts partitions of n distinct items into exactly k nonempty unlabeled groups. S(5, 2) = 15. Group order does not matter.

What happens with zero items or too many groups?

S(0, 0) = 1 for the empty partition. Positive items with zero groups, or more groups than items, give zero.

How does this differ from a Bell number?

Bell numbers count partitions across all possible group counts. Summing S(n, k) for k from zero to n gives B(n). This tool fixes k and calculates second-kind Stirling numbers.

Are results exact and private?

Yes. BigInt arithmetic preserves the entire integer for inputs from 0 to 200. Everything runs in your browser without uploading or storing inputs.