Permutation & combination calculator
Find how many ways you can pick r items out of n: choosing 2 of 5 gives 10 combinations when order does not matter, while permutations count every order separately. Results are exact whole numbers for any n up to 1000. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Total items (n)
- 5
- Selected items (r)
- 2
- Calculation mode
- C
- Result
- 10
Enter n, r and choose permutation or combination to get an exact integer result as a string.
P and C meanings
P(n,r) counts ordered selections of r items from n without replacement, while C(n,r) counts unordered selections. Both require integers n and r between zero and one thousand with r less than or equal to n. Mode accepts P, p, permutation, perm for ordered counts and C, c, combination, comb for unordered counts, then normalizes the echo to a single capital letter.
Results never call the network, never read the system clock and never depend on locale settings of the host.
Exact BigInt products
Permutations multiply the descending product from n down for r factors. Combinations use the same product path with an exact integer division by each successive index, after optionally replacing r with min(r, n-r) so fewer multiplications run. Floats, booleans and padded zeros like 01 are rejected on the offending field.
Results never call the network, never read the system clock and never depend on locale settings of the host.
What the calculator accepts and refuses
A leading minus is reported as negativo before the field name. Values above one thousand fail on n or r. When r is greater than n the match is range.
Empty strings, plus signs and decimal points are format errors. These rules keep the contract short enough for independent oracles to agree on every signed vector without reading implementation code. Results never call the network, never read the system clock and never depend on locale settings of the host.
Pipeline-friendly output
Success responses always include the normalized integers n and r, mode as P or C, result as a minimal decimal string, and formula such as C(5,2) for display. Version one skips repetitions, multinomials and non-integer inputs so the signed surface stays auditable. Results never call the network, never read the system clock and never depend on locale settings of the host.
What you can do with it
Homework checks
Verify textbook nPr and nCr answers instantly.
Lottery style counts
Count unordered draws with C(n,r).
Seating plans
Count ordered assignments with P(n,r).
FAQ
Is the result a number?
It is a decimal string of the exact integer.
What is the difference between a permutation and a combination?
A permutation counts ordered selections, so picking A then B differs from B then A. A combination ignores the order. Choosing 2 of 5 gives 10 combinations, and twice as many permutations because each pair can be arranged two ways.
Which one do I use for lottery draws?
Use a combination, because the order in which the numbers are drawn does not change the ticket. For seating plans or podium places, where the order matters, use a permutation instead.
Can r be larger than n?
No. You cannot pick more items than you have, so r must be equal to or smaller than n. Both must be whole numbers from 0 to 1000, and anything outside that range is refused.
Does it count selections with repetition?
No. Every count assumes that an item, once chosen, cannot be chosen again. Selections with repetition and multinomial counts are not included, so check that your problem draws without replacement.
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/dev/permutation-combination \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":5,"r":2,"mode":"C"}'const res = await fetch("https://api.kit.forhosting.com/dev/permutation-combination", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 5,
"r": 2,
"mode": "C"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/dev/permutation-combination",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 5,
"r": 2,
"mode": "C"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/dev/permutation-combination", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":5,"r":2,"mode":"C"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":5,"r":2,"mode":"C"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/dev/permutation-combination", 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,
"r": 2,
"mode": "C"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "dev.permutation_combination",
"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 | 1000 |
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
P and C meanings
Invalid modes after trim return a typed invalid_input on mode.
Exact BigInt products
Because every step stays on BigInt, values such as P(1000,3) and C(30,5) are exact decimal strings with no scientific notation and no IEEE rounding surprises.
Typed errors and bounds
Missing n, r or mode produce invalid_input with a clear match token.
Integration use cases
CI golden tests
Pin exact string results in continuous integration.
Technical questions
Can r exceed n?
No. That returns range.
Are decimals allowed?
Not in v1. Only integers 0..1000.
How large can n be?
Up to 1000 inclusive.
Free in the browser?
Yes. The widget is local; API uses $0.002.
Does it use Math.pow?
No. Only BigInt products and exact divisions.