Permutation & Combination Calculator
Introduction: why order and repetition change the count
Counting questions look interchangeable until you try to answer them. “How many ways can three of these ten runners finish on the podium?” and “how many three-person committees can these ten people form?” use the same two numbers, yet the answers differ by a factor of six. The gap is not arithmetic sloppiness — it is the honest consequence of two yes/no decisions you make before any formula is chosen:
- Does order matter? Is gold-silver-bronze for Ana, Ben, Chi a different outcome from bronze-silver-gold for the same three people?
- May an item repeat? Can the same digit appear twice in the code, or is every pick removed from the pool?
Two binary choices give four counting rules, and every introductory combinatorics course is built around that 2 × 2 table. This calculator reports all four for the same pair of inputs, so instead of guessing which formula fits, you can read the four candidate answers side by side and pick the one whose assumptions match your problem. The Arrange & Choose game below turns the same 2 × 2 table into something you build by hand: you assemble outcomes from coloured tokens, and the board rejects anything that is not new under the rule currently in force.
Key definitions: the pool, the draw, and the factorial
Three terms carry all of the weight in every formula on this page.
Total items (n)
n is the size of the full pool you draw from. It counts distinguishable items, which is the assumption that quietly breaks most real problems. Examples:
- 10 students in a class: n = 10
- 52 cards in a standard deck: n = 52
- 26 letters of the English alphabet: n = 26
Items chosen (r)
r is how many items you take from the pool in one draw — the number of slots you are filling.
- Creating a 3-person committee from 10 people: r = 3
- Choosing 6 lottery numbers from 49: r = 6
- Drawing a 5-card hand from 52 cards: r = 5
Factorials
Three of the four rules rely on the factorial function. For any non-negative integer n, the factorial of n, written n!, is:
Formula: n ! = ∏ k = 1 n(k)
In plain language, you multiply all positive whole numbers from 1 up to n. For example:
- 1! = 1
- 3! = 1 × 2 × 3 = 6
- 5! = 1 × 2 × 3 × 4 × 5 = 120
By convention, 0! = 1, which is exactly what makes P(n, 0) = C(n, 0) = 1: there is precisely one way to choose nothing.
Formula for permutations P(n, r) when order matters
A permutation counts how many different ordered arrangements you can form when selecting r items from n without repetition. Changing the order produces a different permutation.
The number of permutations is written as P(n, r) and defined by:
Formula: P(n, r) = (n !) / ((n − r) !)
Plain text version: P(n, r) = n! / (n − r)!
The clean way to read this is as a shrinking pool. The first slot has n candidates, the second has n − 1 because one item has been removed, the third has n − 2, and so on for r slots. Multiplying those r factors gives n × (n − 1) × … × (n − r + 1), and dividing n! by (n − r)! is simply a compact way of writing that falling product. The calculator evaluates the product form directly, which is why it never has to build a gigantic factorial just to cancel most of it away again.
Formula for combinations C(n, r) when order does not matter
A combination counts how many different groups of size r you can form from n items when order does not matter. The group {A, B, C} is the same as {C, B, A}.
The number of combinations is written as C(n, r), nCr, or as the binomial coefficient, and is defined by:
Formula: C(n, r) = (n !) / (r !(n − r) !)
Plain text version: C(n, r) = n! / [r! × (n − r)!].
The extra r! in the denominator is the whole story. Every unordered group of r items can be shuffled into r! different ordered arrangements, so the permutation count over-counts each group exactly r! times. Dividing by r! removes the over-count. That single sentence is what the second round of the game makes visible: you build A-then-B, the board accepts it, you build B-then-A, and the board bounces it back with the reason attached.
Formulas for the repetition-allowed cases
Both formulas above assume sampling without replacement: once an item is used it leaves the pool. Drop that assumption and two more rules appear.
Ordered draws with repetition. Every one of the r slots sees the full pool of n items, so the count is a plain power:
Formula: N = n^r
This is the rule behind PINs, licence plates and passwords that allow a repeated character: a 4-digit PIN drawn from 10 digits gives 104 = 10,000 codes, not P(10, 4) = 5,040.
Unordered draws with repetition. Here you are choosing a multiset — three scoops of ice cream where two scoops may share a flavour. The count is:
Formula: N = C(n + r − 1, r) = ((n + r − 1) !) / (r !(n − 1) !)
The standard proof is the “stars and bars” argument: write the r picks as stars and separate the n flavour categories with n − 1 bars. Every arrangement of r stars and n − 1 bars encodes exactly one multiset, and there are C(n + r − 1, r) such arrangements. Notice that this rule stays finite and meaningful even when r is larger than n — you can order five scoops from three flavours — which is why this calculator does not refuse to answer when r exceeds n.
The four counting rules at a glance
The following table is the 2 × 2 decision table in full. Read down the “order matters” column for arrangements and the “order ignored” column for selections.
| Situation | Order matters (arrangements) | Order ignored (selections) |
|---|---|---|
| No repetition (draw without replacement) | P(n, r) = n! / (n − r)! | C(n, r) = n! / [r! (n − r)!] |
| Repetition allowed (draw with replacement) | nr | C(n + r − 1, r) |
| Typical notation | P(n, r) or nPr | C(n, r), nCr, or |
| Example scenario | Assigning gold, silver and bronze to 3 of 10 runners. | Choosing 3 of 10 people to sit on a committee. |
| Value for n = 4, r = 2 | 12 without repetition, 16 with repetition. | 6 without repetition, 10 with repetition. |
| Relationship | P(n, r) = C(n, r) × r! | C(n, r) = P(n, r) / r! |
| Behaviour when r > n | 0 (no such arrangement exists) | 0 without repetition, but still positive with repetition |
How to use this permutation and combination calculator
Only two inputs stand between you and an answer. Put the size of the full pool in Total items (n) — 10 students, 49 lottery balls, or the 52 cards in a deck. Put how many you pull out of that pool in Items chosen (r). Press Calculate counts and the panel returns all four counts at once, together with the r! ratio that links the first two.
Then choose between them with two questions, in this order:
- Can an item be picked twice? If yes, read one of the two repetition-allowed rows. If no, read one of the two no-repetition rows.
- Would swapping two picks give a different outcome? If yes, take the “order matters” value. If no, take the “order ignored” value.
The Reset button clears both fields and the result panel. Every run also writes n and r into the page address, so you can bookmark or share a specific scenario and it will reload already answered. Nothing you type leaves your device.
Worked examples: four problems solved by hand
Example 1: committee versus officer roles
Question: A club has 10 members. How many ways can you choose 3 members to form a committee with no roles, and how many ways can you choose a president, vice president and secretary?
Here n = 10 and r = 3, and no member can hold two seats, so repetition is off.
Committee (order ignored): C(10, 3) = 10! / [3! × 7!]. Compute step by step:
- 10! / 7! = 10 × 9 × 8 = 720
- 3! = 3 × 2 × 1 = 6
- C(10, 3) = 720 / 6 = 120
Officer roles (order matters): P(10, 3) = 10! / 7! = 10 × 9 × 8 = 720.
So there are 120 possible committees but 720 ways to assign three distinct officer roles — a ratio of exactly 3! = 6.
Example 2: lottery numbers
Question: A lottery asks you to choose 6 distinct numbers from 49, and the drawn numbers are not ordered. How many different tickets are possible?
Here n = 49 and r = 6, order is ignored and numbers are not reused, so we use combinations:
C(49, 6) = 49! / [6! × 43!] = (49 × 48 × 47 × 46 × 45 × 44) / 720 = 13,983,816 possible tickets.
A single ticket therefore has roughly a 1-in-14-million chance of matching the draw. The ordered count P(49, 6) = 10,068,347,520 answers a different question — the number of ways the six balls could emerge in sequence — and is 720 times larger.
Example 3: passwords with and without reuse
Question: You create a 3-letter code from the 26 uppercase letters. How many possibilities are there?
Order clearly matters, since ABC differs from CBA, so the answer depends only on whether letters may repeat.
- Distinct letters only: P(26, 3) = 26 × 25 × 24 = 15,600.
- Letters may repeat: 263 = 26 × 26 × 26 = 17,576.
The 1,976 extra codes are exactly the ones containing a repeated letter, such as AAB or XYX. For short codes the gap looks small; for a 10-character code it is the difference between 1.93 × 1013 and 1.41 × 1014, which is why password strength estimates always state whether repeats are allowed.
Example 4: three scoops from five flavours
Question: An ice cream counter has 5 flavours. You order a cup with 3 scoops, scoops may repeat, and the order they are stacked does not matter. How many different cups are possible?
This is the unordered-with-repetition rule with n = 5 and r = 3:
C(5 + 3 − 1, 3) = C(7, 3) = (7 × 6 × 5) / (3 × 2 × 1) = 210 / 6 = 35 cups.
Compare that to C(5, 3) = 10 cups if every scoop had to be a different flavour, and to 53 = 125 if the stacking order were also recorded. Same two numbers, three very different answers.
Reading the four answers together
Because the calculator prints all four counts, the relationships between them become easy to check and hard to misuse.
- P(n, r) = r! × C(n, r). Every unordered group can be shuffled into r! arrangements, so the ordered count is always the larger of the two. The panel prints this identity with your numbers substituted in.
- nr ≥ P(n, r). Allowing repeats can only add outcomes. The extra ones are precisely the arrangements containing at least one duplicate.
- C(n + r − 1, r) ≥ C(n, r). Same logic on the unordered side.
- Order of magnitude is the real message. Once a count climbs into the millions, it is telling you that enumerating outcomes by hand is hopeless and any probability you need has to come from the formula.
A quick sanity habit: if two of your four numbers are equal, check your assumptions. P(n, r) equals C(n, r) only when r is 0 or 1, and nr equals P(n, r) only when r is 0 or 1 as well.
Limitations and assumptions behind these counting formulas
These four rules describe a specific idealised experiment: draws from a fixed pool of distinguishable items, with every outcome treated as equally admissible. Stretch the problem outside that setup and the formulas quietly return the wrong count. Keep the boundaries in mind:
- Non-negative integers only: n and r are whole numbers. Fractional or negative values have no meaning in these formulas, and the calculator rejects them rather than silently truncating.
- Items must be distinguishable: if the pool contains identical items — the letters of MISSISSIPPI, say — you need the multinomial correction n! / (n₁! n₂! … nₖ!) instead. P(n, r) would badly over-count.
- r > n is only meaningful with repetition: the two no-repetition counts are reported as 0, matching the binomial-coefficient convention used by the NIST Digital Library of Mathematical Functions. The two repetition-allowed counts remain valid.
- Counting is not probability: a count becomes a probability only when every outcome is equally likely. Weighted or dependent draws need a probability model, not a counting formula.
- Input ceiling: this page caps n and r at 2,000 so that a mistyped value cannot lock up your browser. The arithmetic itself is exact big-integer arithmetic, so results are not rounded; only the on-screen rendering is abbreviated past 21 digits.
- Estimates for learning: the calculator and the Arrange & Choose game are teaching tools for the counting model itself, not professional statistical advice.
Sources and further reading
The formulas on this page are standard results in combinatorial analysis. The definitions, the r > n convention and the stars-and-bars result were checked against the following references:
- NIST Digital Library of Mathematical Functions, §26.3 Lattice Paths: Binomial Coefficients — defines C(m, n) = m! / [(m − n)! n!] for m ≥ n and fixes the binomial coefficient at 0 when the lower index exceeds the upper index.
- Encyclopedia of Mathematics (EMS Press / Springer), Combination — gives both the ordinary combination count and the combinations-with-repetition count C(m + n − 1, n).
- Kenneth H. Rosen, Discrete Mathematics and Its Applications, 8th edition, McGraw-Hill, 2019 — §6.3 Theorem 1 for P(n, r) = n! / (n − r)!, and §6.5 Theorem 2 for the C(n + r − 1, r) multiset count with the stars-and-bars proof.
Reviewed against NIST DLMF §26.3 and Rosen §6.3 and §6.5. All arithmetic runs locally in your browser using arbitrary-precision integers; no values are transmitted.
Privacy and local computation
All calculations are performed directly in your browser using client-side code. The values you enter for n and r are not sent to a server for processing. This keeps your usage private and ensures that results appear instantly, even if you are offline after loading the page. The only thing that leaves the page is whatever you choose to copy from the address bar.
Related topics worth exploring next
To go deeper into discrete mathematics and probability, these neighbouring ideas build directly on the four rules above:
- Factorials and their growth, including Stirling’s approximation for large n.
- Multinomial coefficients, for splitting n items into several labelled groups at once.
- Binomial coefficients and the binomial distribution, which reuse C(n, r) as a weight.
- Pascal’s triangle, where C(n, r) = C(n − 1, r − 1) + C(n − 1, r) appears as a simple addition rule.
- Inclusion–exclusion, for counting when the “no repetition” assumption is replaced by messier constraints.
Together, permutations and combinations give you a compact language for reasoning about large, complex sets of possibilities without having to list them all individually — although, as the game below shows, listing a few by hand is still the fastest way to believe the formula.
Frequently asked questions about counting arrangements and selections
How do I use this permutation and combination calculator?
Enter the size of your full set in the Total items (n) field, such as 10 students, 49 lottery numbers, or 52 cards, and enter how many items you select at a time in the Items chosen (r) field. Submit the form to see the number of permutations P(n, r), where order matters, and the number of combinations C(n, r), where order does not matter, alongside the two repetition-allowed counts for the same n and r.
What is the difference between a permutation and a combination?
A permutation counts ordered arrangements, so ABC and CBA are different, while a combination counts unordered selections, so ABC and CBA are the same. Because each combination can be arranged in r! different orders, P(n, r) is always r! times larger than C(n, r) for the same n and r.
What happens if r is greater than n?
You cannot draw more distinct items than the pool contains, so the two no-repetition counts are reported as zero, which is the convention the NIST Digital Library of Mathematical Functions uses for the binomial coefficient when the lower index exceeds the upper index. The two repetition-allowed counts stay perfectly meaningful, so the calculator still returns real numbers for them.
Are the results exact for very large values of n?
Yes. Every count is built with arbitrary-precision integer arithmetic rather than floating point, so a value such as C(100, 50) is returned digit for digit instead of being rounded. When a result runs past 21 digits the panel shows a rounded scientific-notation summary plus the exact number of digits, because a 200-digit string is unreadable on a phone.
When should I use the repetition-allowed formulas instead?
Use them whenever an item can be picked more than once. A four-digit PIN reuses digits, so the count is n to the power of r rather than P(n, r). Scooping three cones from five ice cream flavours where two scoops may match is an unordered draw with repetition, so the count is C(n + r - 1, r) rather than C(n, r).
Arrange & Choose: build every outcome by hand
Five rounds, one counting rule each. A tray of coloured tokens sits under a row of empty slots, and your job is to build every distinct outcome the current rule allows — nothing more, nothing less. Fill the slots and the outcome is judged instantly: a genuinely new one flies into the map on the right and lights up its cell, while a repeat is bounced back with the reason written out. Build B then A in an unordered round and the board tells you it is the same combination you already have, and shows you the cell it collided with. The map is the counting structure itself: for two-slot rounds it is an n × n grid where blocked squares are the outcomes the rule forbids and mirrored squares are the ones the rule treats as identical, so the shape of the lit region is the formula. Clear a round and the target count is checked against P(n, r), C(n, r), nr or C(n + r − 1, r).
Keyboard: focus the board, then use ← and → (or ↑ and ↓) to move the token cursor along the tray, Space or Enter to drop the highlighted token into the next open slot, and Backspace to take the last token back. S starts or pauses the round and R restarts it. Pointer or touch: tap a token in the tray to drop it into the next open slot, or drag it straight onto a slot; tap a filled slot to remove that token; tap any cell in the map to hear what that outcome would be.
Rule
1 of 5
Found
0 / 12
Score
0
Best
0
Streak
0
Repeats bounced
0
Time
0:00
Press Start round, then build outcomes from the tray. Duplicates under the current rule are explained rather than counted.
