First kind: permutation cycles
The unsigned number |s(n,k)|, also written c(n,k) or [n k], counts permutations of n labeled elements with exactly k disjoint cycles. The signed convention is s(n,k) = (−1)ⁿ⁻ᵏ|s(n,k)|.
n is the number of labeled elements. k is the number of permutation cycles or nonempty set blocks. Use integers satisfying 0 ≤ k ≤ n ≤ 300.
Whole number from 0 to 300.
Whole number from 0 to n.
Private by design: n and k are validated and calculated on this device. Inputs are not uploaded, saved, or added to the page URL.
The unsigned number |s(n,k)|, also written c(n,k) or [n k], counts permutations of n labeled elements with exactly k disjoint cycles. The signed convention is s(n,k) = (−1)ⁿ⁻ᵏ|s(n,k)|.
S(n,k), also written {n k}, counts ways to partition a set of n labeled elements into exactly k nonempty, unlabeled blocks.
B(n) counts all partitions of an n-element set. It does not fix the number of blocks, so it is the sum of the complete second-kind row.
The empty set has one empty partition, giving s(0,0) = S(0,0) = B(0) = 1. For positive n, values at k = 0 are zero. Values with k > n are mathematically zero, but the calculator asks for k ≤ n so the requested row entry is explicit.
The calculator starts with s(0,0) = |s(0,0)| = S(0,0) = 1 and treats missing row entries as zero.
s(n,k) = s(n−1,k−1) − (n−1)s(n−1,k)
Adding the nth element either creates a new one-element cycle or inserts it into one of the n−1 positions, with the signed convention supplying the minus sign.
|s(n,k)| = |s(n−1,k−1)| + (n−1)|s(n−1,k)|
The recurrence counts both cycle constructions without alternating signs.
S(n,k) = S(n−1,k−1) + kS(n−1,k)
The nth element either forms a new singleton block or joins one of the k existing blocks.
B(n) = ∑ₖ₌₀ⁿ S(n,k)
Summing over every possible number of nonempty blocks counts every set partition exactly once.
s(5,2) = s(4,1) − 4s(4,2)
= −6 − 4(11) = −50
The corresponding unsigned cycle count is 50.
S(5,2) = S(4,1) + 2S(4,2)
= 1 + 2(7) = 15
There are 15 partitions of five labeled elements into two nonempty blocks.
B(5) = 0 + 1 + 15 + 25 + 10 + 1 = 52
There are 52 set partitions of a five-element set across all possible block counts.
The calculator builds the three triangular recurrences row by row through the requested n. It uses JavaScript BigInt values throughout: no floating-point approximation or scientific notation is used. The computation requires O(n²) integer operations and stores only the current and previous rows while calculating.
The first-kind notation varies between sources. This page follows the NIST convention in which lowercase s(n,k) is signed; the nonnegative permutation-cycle count is shown separately as |s(n,k)|. Uppercase S(n,k) denotes the second kind. Inputs are limited to 300 to keep exact row rendering and CSV export responsive on typical phones.
Definitions, recurrence signs, and tabulated values follow the NIST Digital Library of Mathematical Functions section on Stirling numbers. The Bell identity and definition follow its Bell numbers section.
Editorial review: Recurrences, empty-case conventions, and representative outputs checked against NIST DLMF tables. Last reviewed: .
First-kind numbers describe permutations by their number of cycles. Second-kind numbers describe set partitions by their number of nonempty blocks. They use the same inputs but count different objects.
The unsigned value is the actual permutation count. The signed value multiplies that count by (−1)ⁿ⁻ᵏ and appears naturally in algebraic identities involving falling factorials. Because notation is inconsistent across references, this calculator labels and reports both.
Each set partition has some number of blocks from 0 through n. Therefore B(n) = S(n,0) + S(n,1) + ··· + S(n,n).
S(0,0) = 1 because the empty set has one partition into zero blocks. For every positive n, S(n,0) = 0 because a nonempty set cannot be divided into zero blocks.
All three Stirling forms equal 1. The identity permutation is the only permutation with n one-element cycles, and the singleton partition is the only partition into n blocks.
No. Stirling numbers are combinatorial arrays involving cycles and set partitions. Stirling’s approximation estimates factorials; it is a different result named after James Stirling.
Yes. The calculator uses integer recurrences with arbitrary-precision BigInt arithmetic. Commas are display separators and do not indicate rounding.
The values grow rapidly, and a complete row has n + 1 large integers. The limit keeps the exact calculation, display, copying, and CSV download practical on mobile devices.
No. The calculation, copy action, and CSV creation run locally in your browser.