Stirling Numbers Calculator

Explore partitions, permutations, recurrences, and combinatorial growth patterns. Switch kinds, signs, rows, export formats easily. Build confidence with fast, readable, classroom-friendly number tables today.

Calculate Stirling numbers of the first and second kinds, inspect full rows, generate optional triangular tables, and export current results in CSV or PDF form.

Calculator

Input guidance: Use 0 ≤ k ≤ n ≤ 60 for practical table generation. If k is greater than n, the selected term is returned as 0.

Boundary reminder: S(n, 1) = 1, S(n, n) = 1, and S(n, 0) = 0 for n > 0.

Interpretation tip: Second-kind values count set partitions, while first-kind values count permutations grouped by cycle structure.

Example Data Table

These reference values help verify the calculator. They show common textbook outputs for the first and second kinds.
Kind Expression Value Meaning
Second kind S(5, 2) 15 Partitions of five labeled items into two nonempty sets.
Second kind S(6, 3) 90 Partitions of six labeled items into three nonempty sets.
First kind, unsigned c(5, 2) 50 Permutations of five items containing exactly two cycles.
First kind, signed s(5, 2) -50 Signed cycle count from the first-kind recurrence.
First kind, unsigned c(6, 1) 120 All six-item permutations with one cycle.

Formula Used

Second kind: S(n, k) = S(n - 1, k - 1) + k × S(n - 1, k). This adds either a new singleton block or inserts the new element into one of k existing blocks.

First kind, unsigned: c(n, k) = c(n - 1, k - 1) + (n - 1) × c(n - 1, k). The new element either starts a new cycle or joins one of n - 1 positions inside existing cycles.

First kind, signed: s(n, k) = s(n - 1, k - 1) - (n - 1) × s(n - 1, k). The sign alternation is preserved by the subtraction term.

Initial conditions: S(0, 0) = 1, c(0, 0) = 1, and s(0, 0) = 1. For n > 0, the k = 0 boundary is 0, while the diagonal k = n remains 1.

Computation method: This calculator uses dynamic programming with string-based arithmetic. That keeps large values accurate well beyond ordinary integer limits.

How to Use This Calculator

  1. Select the Stirling family you want to study.
  2. Enter n for the total number of labeled elements.
  3. Enter k for the number of blocks or cycles.
  4. Enable the triangle option if you want every row up to n.
  5. Press the calculate button to display the chosen term above the form.
  6. Review the computed row, recurrence, and interpretation notes.
  7. Export the current result as CSV or PDF when needed.

Why These Outputs Matter

Stirling numbers appear across combinatorics, probability, algebra, and algorithm analysis. The second kind connects to set partitions, Bell numbers, and clustering ideas. The first kind connects to permutations, cycle decompositions, falling factorials, and generating function identities.

Showing both the single answer and the entire row helps compare growth patterns. Optional triangle output makes it easier to inspect recurrence behavior, verify boundary conditions, and prepare classroom or research notes.

Frequently Asked Questions

1. What does the second kind count?

It counts ways to divide n labeled objects into k nonempty, unlabeled groups. These values appear in partition problems, clustering models, and Bell number expansions.

2. What does the first kind count?

The unsigned first kind counts permutations of n items with exactly k cycles. The signed version keeps the same magnitude pattern while applying alternating signs from the recurrence.

3. Why can the signed first kind be negative?

The signed recurrence subtracts a scaled previous value. That sign convention is standard in algebraic identities involving falling factorial expansions and inverse coefficient transforms.

4. What happens if k is greater than n?

The calculator returns 0 for that selected term. It still shows the full computed row so you can inspect valid values across the chosen n.

5. Why does the diagonal k = n always equal 1?

There is exactly one way to place each item in its own block. Likewise, there is exactly one identity-style cycle structure with n one-cycles.

6. Why does the row sum change by family?

For the second kind, the row sum gives the Bell number. For the unsigned first kind, it gives n!. For the signed first kind, cancellation changes the total.

7. Are large answers handled accurately?

Yes. The calculator uses string-based arithmetic instead of ordinary machine integers, so large combinatorial values remain exact within the supported input range.

8. When should I show the full triangle?

Use it when you want to verify recurrence patterns, compare nearby rows, prepare lecture notes, or export a fuller reference table for later analysis.

Related Calculators

boolean algebra calculatorset operations calculatorbinary multiplication calculatorcode word generatorfibonacci sequence calculatorbinary subtraction calculatorbinary tree calculatorkarnaugh map calculatorbinary number calculatordivisibility calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.