# How many combinations?

Computes the number of combinations (nCr) of r items chosen from n, with or without repetition, and the matching number of permutations (nPr), exactly.

- Page: https://www.acalculator.org/statistics/combination-calculator
- JSON spec: https://www.acalculator.org/statistics/combination-calculator.json
- Version: 1dbc56b30e2e

## Default answer

Example with the default inputs (Items to choose from (n) 52, Items chosen (r) 5, Can an item be chosen more than once? No): There are 2,598,960 ways to choose 5 items from 52 when order does not matter.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| n | Items to choose from (n) | How many different items there are to choose from. |
| r | Items chosen (r) | How many items are chosen each time. |
| rep | Can an item be chosen more than once? | No: each item at most once (the usual nCr). Yes: an item may be picked again. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| combinations | Combinations | The number of ways to choose r items from n when the order does not matter. |
| permutations | Permutations (order matters) | The number of ways to choose r items from n when the order does matter. |

## Method

Without repetition: C(n, r) = n! ÷ (r! (n − r)!) and P(n, r) = n! ÷ (n − r)!. With repetition: C(n + r − 1, r) and n^r.

## Assumptions

- The n items are all different from each other.
- Without repetition, choosing more items than there are (r > n) gives 0 combinations and 0 permutations.
- Results are exact whole numbers, however many digits they have.

## Worked examples

1. n = 52, r = 5, rep = no gives combinations = 2,598,960, permutations = 311,875,200. Source: hand calculation in content.mdx: 52 × 51 × 50 × 49 × 48 ÷ 120 = 2,598,960 (DLMF 26.3.1); Python math.comb(52, 5) and math.perm(52, 5).
2. n = 49, r = 6, rep = no gives combinations = 13,983,816. Source: hand calculation in content.mdx: 49 × 48 × 47 × 46 × 45 × 44 ÷ 720 = 13,983,816; Python math.comb(49, 6).
3. n = 5, r = 3, rep = yes gives combinations = 35, permutations = 125. Source: hand calculation in content.mdx: C(5 + 3 − 1, 3) = C(7, 3) = 35; 5³ = 125.
4. n = 5, r = 7, rep = no gives combinations = 0, permutations = 0. Source: DLMF 26.3.2: C(m, n) = 0 when n > m; Python math.comb(5, 7) and math.perm(5, 7) are 0.
5. n = 10, r = 0, rep = no gives combinations = 1, permutations = 1. Source: DLMF 26.3.1: C(10, 0) = 10! ÷ (10! 0!) = 1; choosing nothing can be done one way.

## FAQ

### What is the formula for combinations?

The number of ways to choose r items from n different items, when order does not matter, is C(n, r) = n! ÷ (r! × (n − r)!). For 5 cards from a 52-card deck, C(52, 5) = 52! ÷ (5! × 47!) = 2,598,960.

### What is the difference between a combination and a permutation?

In a combination the order does not matter: the hand A, K, Q is the same as Q, K, A. In a permutation the order matters, so those are different. Each combination of r items can be put in order in r! ways, so permutations = combinations × r!.

### What are combinations with repetition?

They count choices where the same item may be picked more than once and order does not matter, such as 3 scoops of ice cream from 5 flavors where two scoops may be the same flavor. The count is C(n + r − 1, r): here C(7, 3) = 35.

### What are the odds of winning a 6 from 49 lottery?

There are C(49, 6) = 13,983,816 ways to choose 6 numbers from 49, and only one of them matches the draw, so the chance of a single ticket winning the jackpot is 1 in 13,983,816.

### Why is C(n, 0) equal to 1?

There is exactly one way to choose nothing: take no items. The formula agrees, because 0! = 1, so C(n, 0) = n! ÷ (0! × n!) = 1.

### What if r is bigger than n?

Without repetition you cannot choose more different items than there are, so the answer is 0 combinations and 0 permutations. With repetition, r can be larger than n, because items can be picked again.

### Why does choosing r items give the same count as choosing n − r?

Every choice of r items to take is also a choice of n − r items to leave behind, so C(n, r) = C(n, n − r). For example, C(10, 3) and C(10, 7) are both 120.

## Sources

- NIST Digital Library of Mathematical Functions, §26.3 Lattice Paths: Binomial Coefficients, equations 26.3.1 and 26.3.2. https://dlmf.nist.gov/26.3
