Combinations and permutations
In a combination, order doesn’t matter, so choosing A then B is the same as B then A. In a permutation, order matters.
Formulas
| Type | Without repetition | With repetition |
|---|---|---|
| Combination | n! ÷ (r! × (n − r)!) | (n + r − 1)! ÷ (r! × (n − 1)!) |
| Permutation | n! ÷ (n − r)! | nʳ |
Here, n is how many items there are, and r is how many you choose.
Worked examples
Choosing 3 from 10:
- Combinations without repetition: 10! ÷ (3! × 7!) = 120
- Permutations without repetition: 10 × 9 × 8 = 720
- Combinations with repetition: 220
- Permutations with repetition: 10³ = 1,000
Which one do I need?
| Question | Use |
|---|---|
| Picking 6 lottery numbers from 49 | Combination: 13,983,816 |
| Gold, silver and bronze from 8 runners | Permutation: 336 |
| A 4-digit PIN | Permutation with repetition: 10,000 |
| 3 scoops from 5 ice cream flavors | Combination with repetition: 35 |
Very large answers
The calculator works these out exactly, for up to 5,000 items. Answers longer than 30 digits are shown in scientific notation.
Combinations with repetition and password combinations
Choose “with repetition” to allow the same item more than once. For unordered picks the count is C(n + r − 1, r)[1]. Wikipedia's example has four types of donut and three donuts to choose, which gives C(6, 3) = 20 ways[1]. Set n = 4, r = 3, choose Combination and With repetition to see 20.
For ordered picks, the number of r-tuples drawn from n items is nr[2]. That is the count for a password or PIN. A password of 8 lowercase letters has 268 = 208,827,064,576 possible combinations, and a 4-digit PIN has 104 = 10,000. Choose Permutation and With repetition, then enter n as the size of the character set and r as the length. The tool does the working in whole numbers, so long answers stay exact. This is a count of possibilities, not a measure of how strong a password is against an attacker.
How to use the combination calculator
- Pick what to count. Under “What do you want to count?”, choose Combinations when the order of the picks doesn’t matter, or Permutations when it does.
- Say whether items can repeat. Under “Can items repeat?”, choose No repeats when each item can be picked only once, or Repeats allowed when the same item can come up again.
- Enter Total items (n). This is how many different items you can choose from.
- Enter Items chosen (r). This is how many you pick each time.
- Press Calculate. Your result opens on the next page. It shows your count and a table with both the combinations and the permutations for the same n and r.
Both boxes take whole numbers from 0 to 5,000.
Worked example: choosing pizza toppings
A pizza shop offers 12 toppings and you want 4 of them. Enter 12 for n and 4 for r.
| Setting | What it counts | Result |
|---|---|---|
| Combinations, no repeats | Four different toppings, in any order | 495 |
| Permutations, no repeats | Four different toppings, where the order you list them matters | 11,880 |
| Combinations, repeats allowed | Four toppings where a double portion of one is allowed | 1,365 |
| Permutations, repeats allowed | An ordered list of four, with repeats | 20,736 |
For a pizza, the order doesn’t matter, so 495 is the answer if every topping is different. Two more examples to try: a committee of 5 people from a club of 20 gives 15,504 combinations, and a 5-card hand from a 52-card deck gives 2,598,960.
Why choosing 7 gives the same count as choosing 3
The number of combinations is also called the binomial coefficient. The NIST Digital Library of Mathematical Functions describes it as the number of ways of choosing a set of objects from a collection of distinct objects without regard to order.[3] It gives the same factorial formula this calculator uses, and it states that choosing n from m gives the same count as choosing m − n from m.[3]
That makes sense once you think about it. Every time you choose 7 people from 10, you also choose the 3 people you leave out. So 10 choose 7 and 10 choose 3 are both 120.
The same library lists the rule behind Pascal’s triangle: the count for m and n equals the count for m − 1 and n plus the count for m − 1 and n − 1.[3] For 10 choose 3, that is 84 + 36 = 120. It also notes that the count is 0 when you try to choose more items than there are.[3] This calculator shows a message in that case instead of a 0, because it is usually a typing mistake.
How the calculator works out big answers
The tool works in whole numbers of any length, so it never rounds a count. For combinations without repeats, it multiplies and divides step by step, using the smaller of r and n − r, so every step stays a whole number. For permutations it multiplies n × (n − 1) × (n − 2) and so on, r times. With repeats allowed, combinations use the formula for n + r − 1 items choose r, and permutations use n to the power r.
Answers up to 30 digits are shown in full with commas. 100 choose 50 has exactly 30 digits, so you see all of them: 100,891,344,545,564,193,334,812,497,256. Longer answers are shown in scientific notation, and the table adds a row with the number of digits. For example, 5,000 choose 2,500 shows as 1.593 × 10^1503, and the table says the answer has 1,504 digits.
Choosing 0 items always gives 1, because there is exactly one way to pick nothing.
Common mistakes with combinations
- Swapping n and r. n is the size of the pool and r is how many you take. Without repeats, r can’t be bigger than n.
- Using combinations when order matters. First, second and third place in a race, or the digits of a code, are ordered. Use Permutations for those.
- Calling a lock code a combination. A three-dial lock with digits 0 to 9 is really an ordered list with repeats, so it has 10 × 10 × 10 = 1,000 codes. Choose Permutations and Repeats allowed.
- Reading the count as a chance. The count tells you how many outcomes there are. If every outcome is equally likely, the chance of one particular outcome is 1 divided by the count. The probability calculator and lottery calculator take it from there.
For arrangements only, you can also use the permutation calculator.
What next
Use this often? Add Combination to your Home screen.
Frequently asked questions
How do I calculate combinations?
Use n! ÷ (r! × (n − r)!). Choosing 3 from 10 gives 10! ÷ (3! × 7!) = 120.
What is the difference between nCr and nPr?
nCr counts groups where order doesn’t matter, and nPr counts arrangements where it does. Choosing 3 from 10 is 120 for nCr and 720 for nPr.
What are the odds of a 6 out of 49 lottery?
There are 13,983,816 combinations, so one ticket has a 1 in 13,983,816 chance.
What does with repetition mean?
It means an item can be chosen more than once, like digits in a PIN.
How many password combinations are there?
With n possible characters and a length of r, there are n to the power r. Eight lowercase letters give 26^8 = 208,827,064,576.
How do I count combinations with repetition?
Use C(n + r - 1, r). Choosing 3 donuts from 4 types gives C(6, 3) = 20.
Sources
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.