Unsigned Stirling numbers of the first kind
Count the arrangements of n items that break into exactly k cycles: 5 items in 2 cycles give 50, 4 items in 2 cycles give 11, and 3 items in one cycle give 2. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Number of elements
- 5
- Number of cycles
- 2
- Value
- 50
- Max n
- 200
- Max k
- 200
This unsigned Stirling numbers of the first kind calculator returns c(n, k), the number of permutations of an n-element set that decompose into exactly k disjoint cycles. The same coefficient appears as the absolute value of the signed Stirling number of the first kind, and it converts rising factorials into ordinary powers in classical special-function identities. Small checks you may already know include five elements and two cycles yielding fifty, four elements and two cycles yielding eleven, and three elements and one cycle yielding two, which is (3−1)!. The engine uses a deterministic BigInt dynamic program based on the recurrence c(n,k)=c(n−1,k−1)+(n−1)·c(n−1,k) only: no network calls, no sampling, and no date-dependent shortcuts.
What these cycle counts mean and what you get
The unsigned Stirling number of the first kind c(n, k) counts how many permutations of n labeled elements have exactly k cycles in their disjoint-cycle decomposition. That combinatorial reading is the one most students meet first: one long cycle on n letters contributes to c(n, 1) equals (n−1)!, the identity permutation contributes only to c(n, n) equals one, and intermediate cycle counts fill the triangle in between. Algebraically the same numbers appear when you expand the rising factorial x(x+1)…(x+n−1) as a polynomial in x with coefficients c(n, k).
This calculator returns the requested n and k, the exact value as a decimal string, a short formula tag such as c(5, 2), and the published maxima so clients can validate before they send a batch. The k-exceeds-n rule matches the mathematical domain: there is no way to partition n elements into more than n cycles.
Where Stirling first-kind counts fit in study, code, and modeling
Students meet unsigned Stirling numbers of the first kind when a textbook asks how many permutations have a given number of cycles, when a rising-factorial expansion exercise needs exact coefficients, or when they must relate cycle index generating functions to ordinary powers. Teachers can pre-generate answer keys for modest n and k without trusting opaque calculator apps that round large integers or silently switch to scientific notation.
Developers call the same contract from scripts to seed deterministic test vectors, to size random-permutation models that condition on cycle count, or to satisfy programming-challenge statements that demand the exact c(n, k) rather than a log-space approximation. Contest practice often needs a fast, offline source of first-kind ranks so solutions can be checked without downloading OEIS tables under time pressure.
Product and research analysts use the count when estimating how many ordered rearrangements of n labeled items fall into a target cycle structure, which appears in card-shuffling, cryptography teaching demos, and basic enumerative combinatorics labs. Pair it with factorial tools when you need (n−1)!
What you can do with it
Homework and cycle-count checks
Look up exact c(n, k) values for textbook exercises on permutations with a fixed number of cycles and rising-factorial expansions.
Contest and model prep
Verify programming-challenge answers and size cycle-conditioned permutation models with exact BigInt coefficients instead of approximations.
FAQ
What does the Stirling first-kind calculator cost?
It is free in your browser on this page.
How is c(n, k) defined?
The unsigned Stirling number of the first kind c(n, k) counts permutations of n elements with exactly k disjoint cycles. It equals the absolute value of the signed Stirling number of the first kind.
Is this the same as Stirling numbers of the second kind?
No. The second kind counts partitions of a set into non-empty unlabeled subsets. This tool only computes the first kind (cycle counts of permutations).
Why is the result a string instead of a number?
Stirling numbers of the first kind grow quickly and can exceed JavaScript safe integers.
What happens if k is larger than n?
The calculation is refused with a clear message, because you cannot split n items into more than n cycles. Enter a number of cycles between 0 and n, up to 200.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/combo/stirling-first \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":5,"k":2}'const res = await fetch("https://api.kit.forhosting.com/combo/stirling-first", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 5,
"k": 2
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/combo/stirling-first",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 5,
"k": 2
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/combo/stirling-first", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":5,"k":2}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":5,"k":2}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/combo/stirling-first", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"n": 5,
"k": 2
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "combo.stirling_first",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_n | 200 |
max_k | 200 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
What unsigned Stirling numbers of the first kind mean and what the response contains
There is no approximate floating-point path presented as truth and no random sampling of permutations: the engine either builds the exact recurrence inside the supported range or rejects the input with invalid_input. Rejected cases include missing n or k, non-integers, fractions, scientific notation, values above the documented ceilings, any negative k, and any k that exceeds n.
How n and k are read and how BigInt keeps every digit exact
Optional leading plus signs are allowed; embedded spaces, hex prefixes, negative signs, and exponential notation are rejected with a clear message so a bad cell does not become a wrong count. Zero for n with k equal to zero returns one, matching the empty-permutation convention used in discrete mathematics. Computation uses an O(n times k) row dynamic program: each row i stores c(i, j) for j up to k by combining the previous-row values with the standard recurrence, so intermediate values stay exact without building full permutation lists. The preferred fields are n for the number of elements and k for the number of cycles, but aliases size and elements for n and cycles and num_cycles for k are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. The engine enforces hard maxima of two hundred on both n and k, which keeps memory and latency inside a predictable budget on the free browser path and on the edge Worker even though cycle counts grow roughly like factorials. Every intermediate is a BigInt and the final value is serialized with toString so JSON never loses digits the way IEEE doubles would after the fifty-third bit. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing Stirling recurrence yourself.
Where Stirling first-kind counts fit in study, code, and modeling
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result. as a special case of c(n, 1), with binomial helpers when you need related combinatorial coefficients, and with other math endpoints when you are building a small lab of free, deterministic combinatorics helpers.
Integration use cases
Deterministic test fixtures
Generate reproducible Stirling first-kind decimal strings for unit tests, property checks, and CI assertions without hand-maintaining tables.
Technical questions
What happens if k is negative or greater than n?
Both cases are rejected with invalid_input. k must be a non-negative integer and must not exceed n.