Stirling Number of the First Kind Calculator

Enter n and k to compute the unsigned Stirling number of the first kind.

Result

225
6
3

How it is calculated

The unsigned Stirling number of the first kind c(n, k) counts the permutations of n items that split into exactly k cycles. The tool builds a table with the recurrence c(n, k) = c(n−1, k−1) + (n−1) × c(n−1, k), starting from c(0, 0) = 1. The idea: item n is either alone in its own cycle, which gives the first term, or it is inserted after any of the other n−1 items in an existing cycle, which gives the second.

Inputs are rounded to whole numbers, k must not exceed n, both must be zero or more, and n is limited to 20; anything else gives no result. For n above 0, c(n, 0) is 0, and c(0, 0) is 1. The results are exact integers, even at n = 20 where the numbers have 18 digits, and they are grouped with your language's thousands separator.

Worked example

Find c(6, 3), the number of permutations of 6 items with exactly 3 cycles. The recurrence gives c(6, 3) = c(5, 2) + 5 × c(5, 3). From the table, c(5, 2) = 50 and c(5, 3) = 35. So c(6, 3) = 50 + 5 × 35 = 50 + 175 = 225. The tool also echoes n = 6 and k = 3. As a sense check, summing c(6, k) over all k gives 720, which is 6!, the total number of permutations of 6 items. At the top of the range, c(20, 1) = 19! = 121,645,100,408,832,000.

Try this example →

Common mistakes

  • Confusing the first kind with the second kind. The first kind counts permutations by cycles; the second kind counts ways to split a set into groups, and the numbers differ (for n = 6, k = 3 the second kind gives 90).
  • Expecting signed values. This tool gives the unsigned (absolute) numbers; the signed version alternates signs and would show negative numbers.
  • Entering k larger than n. There is no way to make more cycles than items, so the tool returns nothing rather than 0.
  • Entering n above 20. The tool stops at 20, and n = 21 gives no result.
  • Typing a decimal such as 5.6 and expecting an error. It is rounded to 6 first, so the result shown belongs to n = 6, and the echoed n confirms which value was used.

About this calculator

The unsigned Stirling number of the first kind, c(n,k), counts the number of ways to arrange n distinct elements into exactly k cycles — closed loops of permutation, as opposed to fixed sequences. They satisfy the recurrence c(n,k) = c(n−1,k−1) + (n−1)·c(n−1,k), building up from the base cases c(0,0)=1 and c(n,0)=0 for n greater than 0.

This calculator computes c(n,k) directly for the n and k you enter. Stirling numbers of the first kind show up in combinatorics, permutation group theory, and the study of algorithms that analyze cycle structure, and they're the coefficients that relate falling factorials to ordinary powers — a useful reference for students and researchers working through combinatorial identities.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    The numbers are coefficients: expand x(x+1)(x+2)(x+3)(x+4)(x+5) and the term in x³ carries 225, which is the tool's answer for n = 6, k = 3. That link is handy for checking a hand expansion or a generating-function exercise. Another reference point is n = 5, k = 5, which returns 1. Values up to n = 20 stay exact, for example 121,645,100,408,832,000 for k = 1. Which counting problem brought you here?

Popular calculators

All Calculators