ForHosting KIT · Math

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
Use it from WebAPIEmailTelegramApp soon
If you enter
Total items (n)
5
Selected items (r)
2
Calculation mode
C
You get
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.

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).

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.

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.

POSThttps://api.kit.forhosting.com/dev/permutation-combination

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.

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"}'
{
  "n": 5,
  "r": 2,
  "mode": "C"
}
{
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_n1000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

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.

CI golden tests

Pin exact string results in continuous integration.

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.

Read the full KIT documentation →