Stirling Numbers Calculator
Calculate the unsigned Stirling number of the first kind, c(n,k), and the Stirling number of the second kind, S(n,k), with exact arbitrary-precision arithmetic and the surrounding rows of both triangles.
Input
Output
| n | c(n, 0..n) — first kind | S(n, 0..n) — second kind |
|---|---|---|
| No data yet | ||
More ways to use this tool
REST API
curl -X POST https://api.iotools.cloud/v1/tool/stirling-numbers-calculator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"n": "6",
"k": "3"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `stirling-numbers-calculator` tool (Stirling Numbers Calculator) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.
Embed widget
<iframe
src="https://iotools.cloud/embed/stirling-numbers-calculator/"
width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
title="Stirling Numbers Calculator — iotools.cloud"
sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
allow="clipboard-write"
style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>Drop this into your own page — free, no key required, just a link back.
| Cost per API/MCP call | From 5 credits |
|---|---|
| Need more credits? | View pricing |
Also available with
Guides
The Stirling Numbers Calculator computes both the unsigned Stirling number of the first kind, c(n, k), and the Stirling number of the second kind, S(n, k) — exactly, with arbitrary-precision arithmetic, plus the surrounding rows of both triangles.
What the two kinds mean
- c(n, k) (unsigned Stirling number of the first kind) — the number of permutations of n elements that have exactly k cycles.
- S(n, k) (Stirling number of the second kind) — the number of ways to partition a set of n elements into exactly k non-empty, unlabeled subsets.
Both are built from the same kind of recurrence, one row at a time:
c(n, k) = c(n-1, k-1) + (n-1)·c(n-1, k)
S(n, k) = S(n-1, k-1) + k·S(n-1, k)with the base case c(0,0) = S(0,0) = 1, and c(n,0) = S(n,0) = 0 for n > 0.
How to use it
- Enter n (the set size) and k (the number of cycles or subsets).
- Read c(n, k) and S(n, k) for the two exact values.
- Check Triangle rows (around n) to see how each value was built, row by row, from row 0 up through row n.
If k is greater than n, both values are 0 — there's no way to arrange n elements into more cycles or subsets than there are elements.
Why exact arithmetic matters
Both kinds grow extremely fast — S(60, 30), for example, is a 54-digit integer. A calculator that computes these with ordinary floating-point numbers silently loses precision well before n reaches 20 (Number.MAX_SAFE_INTEGER is only 2⁵³ − 1). This calculator uses BigInt throughout, so every digit of every value — no matter how large n gets — is exact.
Privacy
This calculator runs entirely in your browser. Your n and k values are never uploaded, logged, or stored.