# Combinations and Permutations Calculator

> Counts the ways to choose k items from n: combinations C(n, k) when order does not matter and permutations P(n, k) when it does, with or without repetition.

- Calculator id: `combinations-permutations` · Category: Math (`math`) · Tool name: `calculate_combinations_permutations`
- Canonical page: https://tttkmbb.com/math/combinations-permutations · This document: https://tttkmbb.com/math/combinations-permutations.md · JSON definition: https://tttkmbb.com/math/combinations-permutations.json

## Purpose

Counts the ways to choose k items from n: combinations C(n, k) when order does not matter and permutations P(n, k) when it does, with or without repetition.

**Use when:** You need nCr (binomial coefficient), nPr, or the number of multisets or sequences of length k drawn from n items.

**Do not use when:** You need the probability of a specific outcome (use probability-of-events or binomial-distribution) or a plain factorial (use factorial).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `n` | integer |  | required | Size of the set. (min 0, max 100000) |
| `k` | integer |  | required | Number of items selected or arranged. (min 0, max 1000) |
| `with_repetition` | boolean |  | optional, default false | true when an item may be chosen more than once (multisets / sequences with replacement). |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `combinations` | number |  | C(n, k) = n! / (k!(n − k)!), or C(n + k − 1, k) with repetition. |
| `permutations` | number |  | P(n, k) = n! / (n − k)!, or n^k with repetition. |
| `expression` | string |  | The formulas with the numbers filled in. |

## Formula

`Without repetition: C(n,k) = n! / (k! (n−k)!), P(n,k) = n! / (n−k)!. With repetition: C = (n+k−1)! / (k! (n−1)!), P = n^k`

Computed with the multiplicative formula (no intermediate factorials) so that n can be large; results above 2^53 are correct to about 15 significant digits.

## Data Sources

- Wikipedia – Combination — https://en.wikipedia.org/wiki/Combination (reference, retrieved 2026-09-23)
- Wikipedia – Permutation — https://en.wikipedia.org/wiki/Permutation (reference, retrieved 2026-09-23)
- NIST Digital Library of Mathematical Functions §26.3 – Lattice paths: binomial coefficients — https://dlmf.nist.gov/26.3 (standard, retrieved 2026-09-23)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/combinations-permutations?n=…&k=…`
- `POST https://tttkmbb.com/api/v1/calculate/combinations-permutations` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/combinations-permutations · OpenAPI operationId `calculate_combinations_permutations` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "combinations-permutations", "inputs": {…}}`

## Example

- Choose 3 of 10: inputs `{"n":10,"k":3,"with_repetition":false}` → `{"combinations":120,"permutations":720,"expression":"C(10,3) = 120; P(10,3) = 720"}`
- Choose 2 of 5 with repetition: inputs `{"n":5,"k":2,"with_repetition":true}` → `{"combinations":15,"permutations":25}`

```
GET https://tttkmbb.com/api/v1/calculate/combinations-permutations?n=10&k=3&with_repetition=false
```

## Limitations

You need the probability of a specific outcome (use probability-of-events or binomial-distribution) or a plain factorial (use factorial). Computed with the multiplicative formula (no intermediate factorials) so that n can be large; results above 2^53 are correct to about 15 significant digits. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Combination or permutation?**

Use combinations when only which items are chosen matters (lottery numbers, committees) and permutations when their order matters (rankings, passwords).

**What happens when k > n without repetition?**

There are no such selections, so both counts are 0.

## Related

- [Factorial Calculator](https://tttkmbb.com/math/factorial.md) — The factorials behind these formulas.
- [Binomial Distribution Calculator](https://tttkmbb.com/statistics/binomial-distribution.md) — Probabilities of k successes in n trials use C(n, k).
- [Probability of Two Events Calculator](https://tttkmbb.com/statistics/probability-of-events.md) — Turn counts of outcomes into probabilities.
