Multinomial coefficient calculator
Count the ways to split items into named groups of set sizes: 6 people placed into three labeled groups of 2 can be arranged in 90 ways, exactly 6! divided by 2! 2! 2!. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- N
- 6
- Groups
- 2, 2, 2
- Quantity
- 90
The multinomial coefficient answers a fundamental counting question: given n distinct items sorted into k labeled groups of sizes n1, n2, through nk, how many distinct assignments exist when order inside each group does not matter? That quantity is written as the multinomial n over n1,n2,…,nk and equals n factorial divided by the product of each group factorial. When there are only two groups it collapses to the familiar binomial coefficient; with three or more groups it counts word rearrangements with repeated letters, contingency-table cells, and ways to deal cards into fixed hands. This capability evaluates the identity with BigInt arithmetic so large coefficients stay exact instead of overflowing floating-point or safe-integer limits.
What the multinomial coefficient means and how it is computed
A multinomial coefficient counts the number of ways to partition a set of n distinct objects into k labeled groups of prescribed sizes n1, n2, through nk that sum exactly to n. The closed form is n factorial over the product of the factorials of those group sizes.
Classic classroom examples make the definition concrete: the number of distinct rearrangements of the letters in MISSISSIPPI is eleven factorial over four factorial times four factorial times two factorial times one factorial, and the number of ways to deal a fifty-two-card deck into four labeled thirteen-card hands is fifty-two factorial over thirteen factorial to the fourth. When k equals two the formula reduces to the binomial coefficient C(n,n1), so multinomials are a strict generalization of n choose r.
Evaluating the factorials naively is disastrous for large n because intermediate values explode long before the final ratio is moderate. This tool therefore multiplies sequential binomials—C(n,n1) times C(n−n1,n2) times the next remaining choose, and so on—using JavaScript BigInt so every intermediate stays exact and the final count is returned as a decimal string.
What you can do with it
Programming contest and interview prep validators
Assert candidate solutions for partition-counting and word-rearrangement problems without reimplementing multiprecision multinomial arithmetic in every language harness.
Multinomial probability and contingency-table demos
Pull exact multinomial coefficients when building multinomial probability tables or teaching contingency tables so the combinatorial factor stays exact before any floating probability step.
FAQ
What is a multinomial coefficient?
It counts ways to partition n distinct items into k labeled groups of sizes n1…nk. It equals n! / (n1! × n2! × … × nk!) and requires those sizes to sum to n.
How is this different from the binomial coefficient (n choose r)?
/ (r! (n−r)!). Multinomials handle three or more group sizes in one coefficient.
Why is the count returned as a string?
Large multinomials exceed JavaScript safe integers. A decimal string keeps the exact value for every supported n without precision loss.
What happens if the group sizes do not sum to n?
The multinomial is only defined here for partitions where n1 + n2 + … + nk equals n exactly.
Is the multinomial coefficient calculator free?
The browser tool is free and runs locally.
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/multinomial \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":6,"groups":[2,2,2]}'const res = await fetch("https://api.kit.forhosting.com/combo/multinomial", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 6,
"groups": [
2,
2,
2
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/combo/multinomial",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 6,
"groups": [
2,
2,
2
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/combo/multinomial", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":6,"groups":[2,2,2]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":6,"groups":[2,2,2]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/combo/multinomial", 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": 6,
"groups": [
2,
2,
2
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "combo.multinomial",
"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 | 10000 |
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
Students, teachers, data scientists, and contest programmers get a deterministic JSON count—no computer-algebra install, no random sampling, and the same pure function in the free browser tool and the prepaid API path—so homework checks, pipeline validation, and interview sandboxes all share one reproducible answer.
What the multinomial coefficient means and how it is computed
Boundary cases are well defined: a single group of size n yields one; all groups of size zero or one when they partition n yield the expected factorial or one; and any input whose group sizes do not sum to n is rejected as invalid_input rather than silently normalizing or inventing an extension. That contract matches standard combinatorics textbooks and programming-contest judges, so you can trust the number against hand calculations for small n and against known tables for larger ones without floating-point drift or silent wraparound.
How to call the API and read the response
Field n is the total number of items—the upper index of the multinomial—and must be a non-negative integer from zero through ten thousand. Field groups is a non-empty array of non-negative integers n1, n2, through nk that form a partition of n: their sum must equal n exactly, and each size must be an integer between zero and n inclusive. /(n1! n2! … nk!) so clients can display or log the identity without hard-coding it. Use it from homework graders, programming-contest validators, interview-prep sandboxes, spreadsheet enrichment jobs, multinomial probability demos that need the coefficient before multiplying by probability powers, contingency-table teaching tools, or any workflow that needs a reproducible multinomial count without installing multiprecision packages on every machine that runs the pipeline. Send a JSON body with two required fields. Aliases total and N are accepted for the same meaning. Aliases parts, sizes, and ni map to groups. A successful response returns n as a number, groups as the coerced integer array, count as a decimal string of the exact multinomial value, and formula as the string n! Failed validation—missing n or groups, a non-array groups field, a non-integer or negative size, a value above the published maximum, an empty groups list, or group sizes that do not sum to n—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price.
Practical tips, limits, and related intents
When teaching, prefer paired examples: n equals six and groups two, two, two yields ninety; n equals five and groups two, one, two yields thirty; n equals ten and groups three, three, four yields four thousand two hundred; n equals five and groups two, two demonstrates the hard rejection path for a sum that is not n; and a negative group size demonstrates the negative rejection path. Sibling landings target ordinary combinations and binomial coefficients; this page is specifically for people searching for a multinomial coefficient calculator, multinomial formula tool, or partition counting helper. Keep n at most ten thousand so worst-case partitions finish quickly on the Worker and in the browser while still covering contest and teaching sizes far beyond safe Number range. If you need multiprecision coefficients with n in the hundreds of thousands, use a dedicated big-integer stack offline—this lightweight parse capability is built for interactive checks, API glue, and classroom demos. Because the sequential-binomial formula is deterministic, students can recompute small cases by hand or with a spreadsheet and match the API line by line. Do not confuse multinomials with permutations of n distinct items or with multinomial probability masses that also multiply by p_i to the n_i—those are different intents and different landings. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when users type bad values while learning the contract. Prefer exact string counts over forcing a JavaScript Number so large coefficients never lose low-order digits in JSON transport.
Integration use cases
Homework and exam grading for multinomial coefficients
Give students n and a group partition and check their hand-computed multinomial against a deterministic API or free browser result without floating-point ambiguity.