Combinations and Permutations Calculator
Count the ways to choose or arrange things. Start from a real situation, like a lottery ticket, a password or a team, and the calculator picks the right formula. It also handles repeated letters, round tables, splitting into groups, "at least one" conditions, lottery odds and the birthday problem. Answers are exact to the last digit.
What are you counting?
Does the order matter?
Yes for rankings, codes and seating. No for teams, hands and tickets.
Can the same item be picked more than once?
Yes for PIN digits and ice cream flavours. No for people and lottery balls.
Use one letter per item. RRRBB means three identical red items and two identical blue ones.
Separate with commas, such as 4,4,4. Everyone ends up in exactly one group.
Check your lottery's current rules. Formats change from time to time.
365 ignores leap years and assumes every day is equally likely.
Results update as you type. Press Calculate or Enter to save one to your recent list.
Your recent calculations
Practice questions
Five fresh questions each time, with worked answers. Teachers can print them as a worksheet with an answer key, or save it as a PDF from the print window.
Two questions pick the formula
Almost every "how many ways" problem comes down to two questions. Does the order matter? And can the same item be picked more than once? The answers point to one of four formulas. Most mistakes come from answering those questions wrongly, not from the arithmetic.
| Order matters? | Repeats? | Name | Formula | Example |
|---|---|---|---|---|
| No | No | Combination | C(n, r) = n! / (r! × (n − r)!) | Lottery tickets |
| Yes | No | Permutation | P(n, r) = n! / (n − r)! | Podium places |
| Yes | Yes | Permutation with repetition | n^r | PIN codes |
| No | Yes | Combination with repetition | C(n + r − 1, r) | Ice cream scoops |
The formulas in plain words
Combination: C(n, r), read "n choose r"
C(n, r) = n! / (r! × (n − r)!)
The number of different groups of r you can pick from n items. n! ("n factorial") means n × (n − 1) × ... × 1. A lottery ticket is a combination: picking 3, 7 and 12 is the same ticket as picking 12, 3 and 7.
Permutation: P(n, r)
P(n, r) = n × (n − 1) × ... × (n − r + 1)
The number of ordered lists of r items from n. For gold, silver and bronze among 10 runners there are 10 choices for gold, 9 for silver and 8 for bronze: 720 results. Arranging all n items is n!, so 10 books can stand on a shelf in 3,628,800 orders.
Permutation with repetition
n^r
Each of the r positions has all n choices. A 4-digit PIN has 10 × 10 × 10 × 10 = 10,000 possibilities.
Combination with repetition ("stars and bars")
C(n + r − 1, r)
Picture your r picks as stars and n − 1 bars dividing them into n kinds. Choosing 3 scoops from 10 flavours is 3 stars and 9 bars, so C(12, 3) = 220 different cups.
Repeated letters, round tables and groups
n! / (a! × b! × ...) (n − 1)! n! / (size₁! × size₂! × ...)
Divide out the swaps that don't change anything: identical letters, rotations of a round table, or the order of people within a group. MISSISSIPPI has 11! / (4! × 4! × 2!) = 34,650 arrangements. Eight people can sit around a round table in 7! = 5,040 ways.
Worked examples
President and treasurer, or a committee of two?
Choosing a president and a treasurer from 10 people is a permutation, because the two jobs are different: 10 × 9 = 90 ways. Choosing a committee of two from the same 10 is a combination, because the two seats are the same: 90 / 2 = 45 ways. Same people, different question.
At least one woman on the committee
A committee of 4 is chosen from 6 women and 8 men. Counting "at least one woman" directly means adding four cases. It's quicker to count all committees, C(14, 4) = 1,001, and subtract the committees with no women, C(8, 4) = 70. That leaves 931.
The birthday problem
In a group of just 23 people, there's a 50.73% chance two share a birthday. Count the ways everyone can have a different birthday, which is P(365, 23), and divide by every possible list of 23 birthdays, which is 365^23. That's the chance of no match, about 49.27%. Subtract from 1 to get 50.73%.
It feels too high because people think about their own birthday. The question is whether any pair matches, and 23 people make 253 pairs. With 57 people the chance passes 99%.
Real-world counts
| Situation | Formula | Count |
|---|---|---|
| Powerball (5 from 69, plus 1 from 26) | C(69, 5) × 26 | 292,201,338 |
| EuroMillions (5 from 50, plus 2 from 12) | C(50, 5) × C(12, 2) | 139,838,160 |
| UK Lotto (6 from 59) | C(59, 6) | 45,057,474 |
| Classic 6 from 49 lottery | C(49, 6) | 13,983,816 |
| 5-card poker hands | C(52, 5) | 2,598,960 |
| 4-digit PINs | 10^4 | 10,000 |
| 8-character passwords from 62 characters | 62^8 | 218,340,105,584,896 |
| Orders of a shuffled 52-card deck | 52! | about 8.07 × 10^67 |
Mistakes that give the wrong answer
Using C(n, r) when roles are different. If the chosen items get different jobs, ranks or positions, order matters, so you need P(n, r).
Forgetting that repeats are allowed. PINs, passwords and licence plates usually allow repeats. Using a no-repeat formula undercounts, sometimes by a lot.
Counting the same thing twice. For "at least one", picking one woman first and then any 3 others counts each committee several times. Subtracting the "none" case avoids that.
Treating a round table like a row. Rotating everyone one seat gives the same neighbours, so divide by the number of seats.
Treating named groups and unnamed groups the same. Splitting 12 people into Team Red, Team Blue and Team Green gives 34,650 ways. If the teams have no names it's 5,775, because swapping two whole teams changes nothing.
How we calculate
Every count on this page uses exact whole-number arithmetic (JavaScript BigInt), so answers are correct to the last digit, however big they get. Numbers with more than 18 digits are shown in short form, with the full number available to view and copy. The calculator stops at answers of about 20,000 digits to keep your browser responsive.
Probabilities in the birthday, lottery and conditions modes are exact fractions converted to percentages only at the last step. Every number in the examples and tables on this page was checked against an independent calculation in Python. If you spot a mistake, let us know and we'll correct it and note the change here.
References
- Sheldon Ross, A First Course in Probability, 10th edition, Pearson, 2019. Chapter 1 covers combinatorial analysis.
- William Feller, An Introduction to Probability Theory and Its Applications, Volume 1, 3rd edition, Wiley, 1968. Chapter 2 covers counting, including the "stars and bars" method.
- Ronald Graham, Donald Knuth and Oren Patashnik, Concrete Mathematics, 2nd edition, Addison-Wesley, 1994.
- Charles Grinstead and J. Laurie Snell, Introduction to Probability, 2nd edition, American Mathematical Society, 1997.
Related calculators
- Binomial Probability Calculator, which uses C(n, k) to count orders of successes
- Card Probability Calculator, which builds hand odds from combinations
- Dice Probability Calculator, for totals, repeated rolls and D&D odds
- Coin Flip Probability Calculator, for streaks, patterns and testing a coin
- Probability Calculator, the full set of tools
Questions people ask
What's the difference between a combination and a permutation?
A combination is a group, so order doesn't matter: a team of Ana, Ben and Cal is the same team in any order. A permutation is an ordered list: Ana first, Ben second and Cal third is different from Ben first, Ana second and Cal third.
Why is nPr never smaller than nCr?
Each group of r items can be put in r! orders, and permutations count every order separately. So P(n, r) = C(n, r) × r!. The two are equal when r is 0 or 1, and P(n, r) is bigger whenever r is 2 or more.
How do I know if repeats are allowed?
Ask whether the same item can be used again. Digits in a PIN and scoops of the same flavour can repeat. People on a team and balls drawn in a lottery can't.
How big can the numbers get?
The calculator works in exact whole numbers, so there's no rounding. It handles answers up to about 20,000 digits. Numbers longer than 18 digits appear in short form, and you can view or copy the full number.
What if r is 0?
There's exactly one way to choose nothing, so C(n, 0) and P(n, 0) both equal 1. This follows from the formula, because 0! is defined as 1.
Why do 23 people give a 50% chance of a shared birthday?
23 people make 253 different pairs, and any one of them matching counts. The chance that all 23 birthdays are different is about 49.27%, so the chance of at least one shared birthday is about 50.73%.
How are lottery odds worked out?
Count the possible tickets with combinations and multiply by the bonus ball choices. Powerball is C(69, 5) × 26 = 292,201,338 tickets, so one ticket has a 1 in 292,201,338 chance of the jackpot.