Permutation and Combination Calculator
Exact counts of arrangements and selections, with or without repeats, and the steps behind each one.
Results
Combinations (nCr)
126
C(9, 4): ways to choose 4 of 9 different items when order doesn't matter
All four counts for n = 9 and r = 4
Select a case to make it the answer above; the two questions change to match.
- Chance of one particular selection
- 1 in 1260.794%, if all 126 selections are equally likely
- Orderings of each selection (4!)
- 24so nPr = 126 × 24 = 3,024
- Digits
- 3exact whole number
How this was calculated
- Formula: C(n, r) = n! ÷ (r! × (n − r)!), where n! = n × (n − 1) × ⋯ × 2 × 1 and 0! = 1
- C(9, 4) = 9! ÷ (4! × 5!)
- Cancel 5! from the top and bottom: (9 × 8 × 7 × 6) ÷ (4 × 3 × 2 × 1)
- = 3,024 ÷ 24 = 126
- In Excel:
=COMBIN(9, 4)gives 126.
| # | Selection |
|---|---|
| 1 | ABCD |
| 2 | ABCE |
| 3 | ABCF |
| 4 | ABCG |
| 5 | ABCH |
| 6 | ABCI |
| 7 | ABDE |
| 8 | ABDF |
| 9 | ABDG |
| 10 | ABDH |
| 11 | ABDI |
| 12 | ABEF |
| r | nPr | nCr | nʳ | C(n+r−1, r) |
|---|---|---|---|---|
| 0 | 1 | 1 | 1 | 1 |
| 1 | 9 | 9 | 9 | 9 |
| 2 | 72 | 36 | 81 | 45 |
| 3 | 504 | 84 | 729 | 165 |
| 4 (your r) | 3,024 | 126 | 6,561 | 495 |
| 5 | 15,120 | 126 | 59,049 | 1,287 |
| 6 | 60,480 | 84 | 531,441 | 3,003 |
| 7 | 181,440 | 36 | 4,782,969 | 6,435 |
| 8 | 362,880 | 9 | 43,046,721 | 12,870 |
| 9 | 362,880 | 1 | 387,420,489 | 24,310 |
The nCr column is row 9 of Pascal's triangle; it reads the same both ways because C(n, r) = C(n, n − r).
Assumptions
- The n items are all different from each other. For look-alike items (letters of a word), choose "Arranging a word or look-alikes".
- Order is ignored: AB and BA are the same selection and count once.
- Each item can be picked at most once, so r larger than n gives 0 (not an error).
- Counts up to 10,000 digits are exact whole numbers; longer ones are log-gamma estimates, marked as such.
- The "1 in N" chance assumes every outcome is equally likely, as in a fair draw.
Calculated in your browser. This site doesn't send the numbers you enter anywhere. “Continue in” links pass them to the next calculator within this browser tab only.
What this calculator answers
How many ways there are to pick or arrange things: 4 people for a committee out of 9, 3 medal winners out of 8 runners, a 4-digit code, 6 lottery numbers out of 49, 3 scoops from 5 flavors, or the letters of a word such as MISSISSIPPI. Answer two plain questions (does the order matter, and can an item be picked twice?) and it gives the count for your case, the other three cases next to it, and the factorial steps with your numbers. Results are exact whole numbers up to 10,000 digits.
How to use it
- What are you counting? Keep “Choosing r of n different items” for most questions. Choose “Arranging a word or look-alikes” when some items are identical, like the letters of a word or flags that come in colors.
- Total items (n): how many different items there are to choose from, such as 9 people or the 10 digits 0 to 9. Whole numbers from 0 to 1,000,000.
- Items chosen (r): how many you pick, or how many places you fill, such as 4 committee seats or the 4 digits of a code. Also 0 to 1,000,000.
- Does the order matter? Yes when swapping two picks gives a different outcome: race places, a PIN, officers with titles. No when only the group counts: a committee, a hand of cards, a lottery ticket.
- Can an item be chosen more than once? Yes for digits in a code or scoops of the same flavor; no for people, cards or lottery balls.
- Word or letters or Group sizes (arrangements only): type the word, or the sizes of the identical groups separated by commas, like
3, 2, 1.
Results update as you type. The Try buttons load a podium (top 3 of 8), a 4-digit lock code, a 6-of-49 lottery, 3 scoops from 5 flavors, the letters of MISSISSIPPI and every order of a 52-card deck. In the grid of four counts, select any case to make it the answer; the two questions switch to match. When there are 200 outcomes or fewer, each of up to 12 items, the page lists every one of them, labeled A, B, C and so on. A second table always shows the counts for nearby values of r. Both tables download as CSV files. Save for comparison keeps up to three results side by side, and Continue in the Scientific Calculator carries a count of up to 15 digits over as nCr(9, 4), nPr(9, 4) or 9^4, so you can use it in a longer calculation such as a probability.
Permutation or combination? Does the order matter?
It’s a permutation when the order of the picks matters and a combination when it doesn’t. A quick test: swap two of the chosen items. If that gives a different outcome (gold and silver trade places), order matters. If it’s still the same outcome (the same committee), order doesn’t matter.
The second question, whether an item can be picked again, splits each of those in two:
| Can an item repeat? | Order matters | Order doesn’t matter |
|---|---|---|
| No | Permutations, nPr: a podium finish | Combinations, nCr: a lottery ticket |
| Yes | nʳ: a lock code | C(n + r − 1, r): scoops of ice cream |
Permutations formula (nPr)
- is the number of different items and the number placed in order.
- (n factorial) is , and .
Everything in cancels, so nPr is the first factors of : . Gold, silver and bronze among 8 runners: possible podiums.
Combinations formula (nCr, “n choose r”)
A combination ignores order, so each group of items that nPr counts times in its different orders is counted once. A lottery draw of 6 numbers from 49 has C(49, 6) = 13,983,816 possible tickets, so one ticket has a 1 in 13,983,816 chance of matching all six.
Permutations with repetition (nʳ)
When every one of the positions can hold any of the items, multiply by itself times: . A 4-digit code from the digits 0 to 9 has possibilities. Only 10 × 9 × 8 × 7 = 5,040 of them use four different digits, so 4,960 repeat at least one digit. The calculator shows that split under the result.
Combinations with repetition: C(n + r − 1, r)
Choosing items from kinds when a kind can be picked again, and order doesn’t matter, is counted by
Think of the picks as stars and of bars that split them into the kinds: every selection is one way to place the stars among spots. Three scoops from 5 flavors: C(7, 3) = 35 cups, of which C(5, 3) = 10 have three different flavors.
Worked example: a committee of 4 from 9 volunteers
A club needs a committee of 4 from 9 volunteers. A person can’t serve twice, and the committee has no ranks, so order doesn’t matter and nothing repeats: a combination.
- Formula: C(9, 4) = 9! ÷ (4! × 5!).
- Cancel 5! from the top and bottom: (9 × 8 × 7 × 6) ÷ (4 × 3 × 2 × 1).
- Multiply: 3,024 ÷ 24 = 126 possible committees.
- If the four seats have titles (chair, vice-chair, secretary, treasurer), order matters: P(9, 4) = 9 × 8 × 7 × 6 = 3,024. That is 126 × 24, because each committee can share out its four titles in 4! = 24 ways.
- If the committee is drawn at random, one particular group of four has a 1 in 126 chance, about 0.794%.
The same count in a spreadsheet is =COMBIN(9, 4), and =PERMUT(9, 4) for the titled version.
Arrangements of a word with repeated letters
Swapping two identical letters doesn’t make a new word, so divide the arrangements of all the letters by the orderings of each repeated letter:
MISSISSIPPI has 11 letters: M once, I four times, S four times and P twice. That gives 11! ÷ (1! × 4! × 4! × 2!) = 39,916,800 ÷ 1,152 = 34,650 distinct arrangements. Items that come in look-alike groups work the same way: 3 red, 2 blue and 1 green flag in a row can be ordered 6! ÷ (3! × 2! × 1!) = 720 ÷ 12 = 60 ways. Choose “Group sizes” and type 3, 2, 1 for that. In Excel, =MULTINOMIAL(1, 4, 4, 2) gives the MISSISSIPPI count.
Very large results: exact digits and scientific notation
Counts grow fast. The orderings of a deck of 52 cards are 52! = 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000, a 68-digit number, or about . The calculator uses whole-number arithmetic, so every digit is exact, and it shows the digits in a box with a button that copies all of them.
Up to 10,000 digits the count is exact. Beyond that, it is estimated from the log-gamma function and marked with ≈, showing only the leading digits that are reliable; n = 1,000,000 with r = 1,000,000 in order gives . Spreadsheets store numbers in floating point instead: Excel keeps 15 significant digits and can’t hold a number above about , so it can show 170! (about ) but not 171! (about ).
When r is bigger than n, or r or n is 0
- r bigger than n, no repeats: there is no way to pick 5 different items from 3, so nPr and nCr are 0. The page says so and offers to swap n and r or allow repeats, where Excel’s PERMUT and COMBIN return #NUM!. With repeats the question makes sense: 3 items fill 5 places in 3⁵ = 243 ordered ways, and there are C(7, 5) = 21 unordered selections.
- r = 0: choosing nothing can be done exactly one way, so every count is 1. That is why 0! is defined as 1.
- n = 0: with nothing to choose from, the only possible choice is choosing nothing (r = 0), which counts 1; any r above 0 gives 0.
Reading the result
- The headline is the count for your answers to the two questions (or the number of distinct arrangements), with the formula and your numbers underneath.
- All four counts shows nPr, nCr, nʳ and C(n + r − 1, r) for the same n and r, so you can see how much each answer changes the count.
- The tiles give the chance of one particular outcome when all are equally likely, how the case links to its neighbor (nPr = nCr × r!, or how many outcomes repeat an item) and the number of digits.
- How this was calculated shows the formula, the canceled factorials and the spreadsheet function that gives the same count.
- The list writes out every outcome when there are 200 or fewer, labeling the items A, B, C and so on (or 1, 2, 3 above 26 items). It is the quickest way to check that you picked the right case.
- Counts for other values of r runs r from 0 to n when n is 20 or less (the nCr column is then row n of Pascal’s triangle), or 5 either side of your r when n is larger or r is far above n.
Common mistakes
- Using nPr for a committee or a hand of cards. It counts each group once per ordering: 3,024 instead of 126 for 4 of 9 people.
- Using nCr for anything ranked or coded. Race places, passwords and PINs depend on order.
- Forgetting that items can repeat. A 4-digit code has 10,000 possibilities, not the 5,040 with all-different digits.
- Using nʳ for scoops or other unordered picks with repeats. 5³ = 125 counts vanilla-then-chocolate and chocolate-then-vanilla separately; the number of different cups is 35.
- Dividing nʳ by r! to remove the order. With repeats that isn’t a count at all: 10,000 ÷ 24 is not a whole number. Use C(n + r − 1, r).
- Treating identical items as different. MISSISSIPPI has 34,650 distinct arrangements, not 11! = 39,916,800.
- Swapping n and r. n is the pool, r is how many you take; C(4, 9) is 0 but C(9, 4) is 126.
Assumptions and limitations
- In “Choosing r of n different items” the n items are all different from each other. Use arrangements for look-alike items.
- Arrangements are in a line with a first and a last place. Seats around a round table count fewer, because turning everyone one seat is the same seating.
- Restrictions such as “A and B must sit together” or “at least one of each color” need extra steps; count each allowed case and add them up, or count the opposite and subtract.
- Counts up to 10,000 digits are exact; longer ones are estimates, marked on the page.
- The “1 in N” chance assumes every outcome is equally likely, as in a fair draw.
Questions
Is a combination lock a combination or a permutation?
Mathematically it isn’t a combination, because the order of the numbers matters (1-2-3 won’t open a lock set to 3-2-1). If the code may use a number twice, it is a permutation with repetition, nʳ, so a dial with 40 numbers and a 3-number code allows 40 × 40 × 40 = 64,000 codes. If every number in the code must differ, it is a permutation, P(40, 3) = 40 × 39 × 38 = 59,280.
How do I turn a count into a probability, such as a poker hand?
Count the outcomes you want and divide by all outcomes, counted the same way. There are C(52, 5) = 2,598,960 five-card hands. Four aces plus any one of the other 48 cards makes 48 hands, so the chance of being dealt four aces is 48 ÷ 2,598,960, or 1 in 54,145. Keep both counts as combinations (or both as permutations); mixing them is off by a factor of 5! = 120.
Sources
- Contemporary Mathematics, 7.1 The Multiplication Rule for Counting OpenStax (Rice University) Multiplying the number of choices at each step, as in 26 × 26 × 26 × 10 × 10 × 10 license plates; the basis of nʳ when an item can be picked again.
- Contemporary Mathematics, 7.2 Permutations OpenStax (Rice University) A permutation is an ordered list with no repeated items; nPr = n! ÷ (n − r)!; the definition 0! = 1.
- Contemporary Mathematics, 7.3 Combinations OpenStax (Rice University) nCr = n! ÷ (r! (n − r)!) and nPr = nCr × r! (each selection can be put in order r! ways).
- Digital Library of Mathematical Functions, §26.17 The Twelvefold Way NIST All four counts in one table: nʳ with repeats and order, the falling product without repeats, C(n + r − 1, r) for unordered picks with repeats and C(n, r) without.
- Digital Library of Mathematical Functions, §26.4 Multinomial Coefficients NIST The multinomial coefficient n! ÷ (n₁! n₂! ⋯ n_k!) and its product-of-binomials form.
- Digital Library of Mathematical Functions, §26.16 Multiset Permutations NIST The distinct orderings of a collection with repeated items number exactly the multinomial coefficient.
- Digital Library of Mathematical Functions, §5.11 Gamma Function: Asymptotic Expansions NIST Stirling’s series for ln Γ, behind the estimates used past 10,000 digits.
- Excel functions (alphabetical) Microsoft Support What COMBIN, COMBINA, PERMUT, PERMUTATIONA and MULTINOMIAL return.
- COMBIN function Microsoft Support COMBIN returns
- PERMUT function Microsoft Support PERMUT returns
- Excel specifications and limits Microsoft Support Excel keeps 15 significant digits and its largest number from a formula is about 1.8 × 10^308.
Smart Financial Calc: https://smartfinancialcalc.com/math/permutation-combination-calculator/