What are permutations and combinations?
A permutation counts arrangements where order matters, and a combination counts selections where order does not matter. If three finalists A, B and C stand on a podium, gold-silver-bronze in the order A, B, C is a different result from B, A, C, so podium finishes are permutations. If the same three people are simply chosen for a committee, the set A, B, C is one outcome however you list it, so committee choices are combinations. Almost every counting question in school mathematics, probability, cards, lotteries and coding reduces to deciding which of those two ideas applies, and then deciding a second question: can the same item be used more than once? Those two yes-or-no decisions produce exactly four formulas, and this permutation and combination calculator evaluates all four together for any n and r you enter, so you never have to guess which row of the table your problem belongs to before you can see a number.
The notation is compact. In nPr, n is the total number of distinct items available and r is the number you take, and the value counts ordered arrangements without reuse. In nCr, the same n and r count unordered selections without reuse. The letters themselves are the memory aid generations of students have used: P for permutation, where position matters, and C for combination, where only the collection matters. A useful everyday test is to swap two of your chosen items in your head. If swapping them creates a genuinely different outcome - a different code, a different finishing order, a different sequence - you need a permutation. If the swapped version is the same outcome described in a different order - the same hand of cards, the same team, the same set of toppings - you need a combination. Getting that judgement right matters, because the two answers for the same n and r differ by a factor of r factorial.
How this permutation and combination calculator works
This page is deliberately built as a combined nPr and nCr calculator rather than two separate tools, because in real problems the two values are almost always wanted together, and seeing them side by side teaches the relationship between them. Type n and r and four rows appear. The headline shows the permutation count without repetition. Three summary pills show the combination count, the permutations with repetition count, and the combinations with repetition count. Below them, a breakdown lists every result again with its name in full, and a formulas panel writes out each formula with your actual numbers substituted into it - for example, with n = 10 and r = 3, you see 10! / 7! for the permutation and 10! / (3! x 7!) for the combination, followed by the evaluated factorials and the final answer.
Under the surface, the arithmetic avoids the naive route of computing three enormous factorials and dividing them, even though the formulas are written that way. A permutation is calculated as a falling product, multiplying only the r terms that survive cancellation: n x (n - 1) x ... x (n - r + 1). A combination is calculated by an iterative multiply-and-divide loop in which every intermediate step is itself an exact whole number - at step k the running value is exactly C(n - r + k, k) - so the division at each step comes out even and no fraction ever appears. Permutations with repetition use exact integer exponentiation, and combinations with repetition reuse the same exact combination routine on n + r - 1 choose r. All of this is done with JavaScript BigInt values, which are integers of unlimited size, rather than ordinary floating-point numbers, which stop being exact integers beyond 2 to the power 53. Nothing is uploaded: the calculation happens entirely in your browser tab.
Validation is part of the working. Both inputs must be non-negative whole numbers within the stated cap. If r is larger than n, the two without-repetition rows are marked undefined with a plain explanation that you cannot arrange or choose more distinct items than exist, while the two with-repetition rows still return their valid values, because reuse means the supply never runs out. That split behaviour mirrors the mathematics exactly.
The four formulas at a glance: which formula when?
Every problem this calculator solves fits one cell of a two-by-two table. Read across by asking whether order matters, and read down by asking whether repetition is allowed. The table below is the whole decision procedure, and the guide sections that follow take each cell in turn.
| Formula | Order matters? | Repetition allowed? | Use it when | Example |
|---|---|---|---|---|
| nPr = n! / (n - r)! | Yes | No | Arranging r distinct items from n: finishing orders, rankings, codes with no repeated symbol | 10P3 = 720 |
| nCr = n! / (r! x (n - r)!) | No | No | Choosing r distinct items from n: teams, committees, card hands, lottery tickets | 10C3 = 120 |
| n^r | Yes | Yes | Filling r positions, each independently from n options: PINs, passwords, licence plates | 5^3 = 125 |
| C(n + r - 1, r) | No | Yes | Choosing r items from n types with repeats allowed: scoops, coins, distributing identical items | C(7, 3) = 35 for n = 5, r = 3 |
Permutations without repetition (nPr) in depth
The permutation calculator formula, nPr = n! / (n - r)!, is best understood as a cancellation. Arranging all n items gives n! orders. If you only care about the first r positions, then for any fixed arrangement of those r, the remaining n - r items can be arranged behind them in (n - r)! ways, all of which look identical from the front. Dividing n! by (n - r)! removes exactly that invisible tail, leaving the count of visibly different front sections. Equivalently, build the arrangement position by position: n choices for the first place, n - 1 for the second because one item is used up, down to n - r + 1 choices for the r-th place. Multiplying those r falling terms gives the same number, and that falling product is what this calculator actually multiplies, term by term, in exact arithmetic.
The anchor example is 10P3 = 720. Ten athletes contest a race and you count the possible gold, silver and bronze outcomes: 10 choices for gold, 9 for silver, 8 for bronze, and 10 x 9 x 8 = 720. The formula agrees: 10! / 7! = 3,628,800 / 5,040 = 720. Two edge cases complete the picture. When r equals n, the denominator is 0!, which is 1, so nPn = n! - arranging everything is just the factorial itself. When r equals 0, there is exactly one arrangement, the empty one, so nP0 = 1. Both edges fall out of the same formula with no special pleading, provided you accept the standard and necessary convention that 0! = 1.
Combinations without repetition (nCr) in depth
The combination calculator formula, nCr = n! / (r! x (n - r)!), adds one more division to the permutation formula, and that division has a concrete meaning. Start with all ordered arrangements, n! / (n - r)!. Every unordered selection of r items appears among them not once but r! times, once for each order its items can be listed in. Dividing by r! therefore collapses each bundle of r! orderings into the single selection it represents. For n = 10 and r = 3, that is 720 / 6 = 120, matching the direct formula 10! / (3! x 7!) = 120. This is also the fastest sanity check in the whole topic: for any inputs, nCr multiplied by r! must equal nPr exactly, and both numbers are on this page for you to test it.
The most famous combination in everyday life is 52C5 = 2,598,960, the number of distinct five-card hands from a standard deck. Order is irrelevant to a poker hand - the same five cards dealt in a different sequence are the same hand - and no card repeats, so the combination formula applies directly: 52! / (5! x 47!) = 2,598,960. Every poker probability is a ratio built on that denominator, and every lottery jackpot odds figure is built the same way: count the winning selections, divide by the total selections. A second structural fact is worth memorising: symmetry. Choosing r items to take is the same act as choosing n - r items to leave behind, so nCr always equals nC(n - r). Hence 10C3 = 10C7 = 120, and 52C5 = 52C47. This calculator's iterative method quietly exploits the same symmetry by always iterating over the smaller of r and n - r, which is why large combinations stay fast.
Permutations with repetition (n^r)
When every one of the r positions can independently use any of the n options, the multiplication principle gives the simplest formula of the four: n multiplied by itself r times, n^r. Nothing is used up, so the falling pattern of the ordinary permutation never starts: the second position still offers n choices, and so does the last. The worked example used throughout this page is n = 5, r = 3: 5^3 = 5 x 5 x 5 = 125. Think of a three-character code built from five allowed symbols where symbols may repeat: AAA and AAB are both allowed, which is precisely what repetition means, and there are 125 such codes. Compare the no-repetition answer for the same numbers, 5P3 = 60: allowing repetition more than doubles the count here, and the gap widens violently as r grows, because n^r is exponential in r while nPr stops entirely at r = n.
Combinations with repetition and stars and bars
The subtlest of the four formulas counts selections where order does not matter but repeats are allowed: choosing r items from n types, where the same type may be taken several times. The answer is C(n + r - 1, r), also written with n + r - 1 over r as a binomial coefficient and sometimes called multichoose. The standard example on this page is n = 5 types with r = 3 choices: C(5 + 3 - 1, 3) = C(7, 3) = 35. Picture choosing three scoops from five ice-cream flavours where a triple scoop of one flavour is allowed.
The proof behind the formula is the celebrated stars and bars argument, and it is short enough to give in full. Represent a selection by r stars placed in a row, divided into n type-bins by n - 1 bars. For example, with five flavours and three scoops, the arrangement star-bar-star-bar-bar-star-bar means one scoop of flavour one, one of flavour two, none of flavour three, one of flavour four and none of flavour five. Every selection corresponds to exactly one string of r stars and n - 1 bars, and every such string corresponds to exactly one selection. A string has n + r - 1 symbols in total, and it is fully determined by choosing which r of those positions are stars - or equivalently which n - 1 are bars - so the count is C(n + r - 1, r), which also equals C(n + r - 1, n - 1). The same argument counts the number of ways to distribute r identical balls into n distinct boxes, and the number of non-negative whole-number solutions to an equation such as a + b + c + d + e = 3, which is why this formula appears in probability, statistics and computer science far beyond ice cream.
Worked examples: from 10P3 to 100C50
Example 1 - podium finishes, 10P3. Ten runners, three distinct medals, no repetition: 10P3 = 10! / 7! = 10 x 9 x 8 = 720 possible medal outcomes. The matching selection question - which three runners win a medal, ignoring which medal - is 10C3 = 120, and 720 divided by 120 is 6 = 3!, the orders of any three medalists, exactly as the theory requires.
Example 2 - card hands, 52C5. Five cards from 52, order irrelevant, no repeats: 52C5 = 52! / (5! x 47!) = (52 x 51 x 50 x 49 x 48) / 120 = 311,875,200 / 120 = 2,598,960 distinct hands. Enter n = 52 and r = 5 above and the same figure appears, alongside 52P5 = 311,875,200 ordered deals, which is larger by exactly the factor 5! = 120.
Example 3 - codes with repetition, 5^3. Three positions, five symbols each, repeats allowed: 5^3 = 125. The combinations with repetition for the same inputs - unordered selections of three symbols from five types with repeats - is C(7, 3) = 35. Putting 125 and 35 side by side shows the full effect of order: of the 125 ordered codes, order-blindness collapses them into just 35 multisets.
Example 4 - a large exact value, 100C50. Choosing 50 from 100 is the largest combination with n = 100, and its exact value is 100,891,344,545,564,193,334,812,497,256 - thirty digits, every one of them correct on this page. No ordinary calculator can show you that number in full: floating-point arithmetic carries only about sixteen significant digits. Exact BigInt arithmetic is not a luxury at this scale, it is the difference between the answer and an approximation of it. The reference table below gathers the values used in this guide; every one was produced by the same routines this calculator runs, so you can reproduce each row by entering its n and r above.
| Expression | Meaning | Exact value |
|---|---|---|
| 10P3 | Ordered arrangements, no repetition | 720 |
| 10C3 | Unordered selections, no repetition | 120 |
| 52C5 | Five-card poker hands | 2,598,960 |
| 52P5 | Ordered five-card deals | 311,875,200 |
| 5^3 | Permutations with repetition, n = 5, r = 3 | 125 |
| C(7, 3) | Combinations with repetition, n = 5, r = 3 | 35 |
| 10^3 | Permutations with repetition, n = 10, r = 3 | 1,000 |
| C(12, 3) | Combinations with repetition, n = 10, r = 3 | 220 |
| 100C50 | Largest combination for n = 100 | 100,891,344,545,564,193,334,812,497,256 |
Common permutation and combination mistakes
Using permutations when order does not matter. The costliest error in the topic. A lottery ticket, a committee and a card hand are combinations; counting them as permutations inflates the total by r factorial and destroys any probability built on it. Run the swap test from the first section before touching a formula. Forgetting that repetition changes the formula entirely. A code with repeated digits is not a permutation in the nPr sense at all: 10P4 = 5,040 counts only no-repeat codes, while all four-digit PINs number 10^4 = 10,000. Writing nCr with the wrong denominator. It is r! times (n - r)!, both factorials, every time; dropping the (n - r)! term is a frequent slip that the substituted formula panel on this page makes easy to catch.
Applying the without-repetition formulas when r is larger than n. There are zero ways to choose more distinct items than exist in the ordered sense the formulas describe - the expressions are simply undefined, because (n - r)! would be the factorial of a negative number. This calculator says so plainly rather than returning a misleading zero, while still showing the repetition results that remain valid. Off-by-one in combinations with repetition. The total is n + r - 1: students who write C(n + r, r) overcount systematically. Check with the tiny case n = 1: any r must give exactly 1 selection, and C(1 + r - 1, r) = C(r, r) = 1, while C(1 + r, r) = r + 1 fails the test.
Limits, exactness and honesty
The cap and the honesty rules of this page are stated openly. Results are exact counts. No result is estimated, rounded, or abbreviated into scientific notation in place of the answer: the full integer is always displayed with thousands separators and is available in full in the copy and download output. The methods are exact by construction - falling products for permutations, a multiply-and-divide loop whose every intermediate value is a whole number for combinations, and exact integer exponentiation for n^r. The one performance caveat is real and is stated rather than hidden: for very large inputs, such as n and r both near the 1,000 cap, the page computes exact BigInt values but may take a moment, since a result can run to thousands of digits - 1000^1000 alone has 3,001 digits. The 1,000 cap exists to keep every permitted calculation finishable in a browser tab and every result readable once it arrives. This calculator covers the four standard models only: it does not handle partial repetition limits, circular arrangements, or derangements, and the guide says so rather than letting a near-miss formula stand in for them.
Sources and References
- Wolfram MathWorld - Permutation - definition and the nPr formula
- Wolfram MathWorld - Combination - definition and the nCr formula
- Wolfram MathWorld - Binomial Coefficient - properties and identities of nCr
- Wolfram MathWorld - Multichoose - combinations with repetition
- Wikipedia - Permutation - permutations with and without repetition
- Wikipedia - Combination - combinations, stars and bars and worked examples
- Math is Fun - Combinations and Permutations - an accessible introduction with examples
Every figure in this guide was calculated with this page's own method, so you can reproduce each one exactly by entering the same numbers above. All seven sources above were checked live while this page was written and returned HTTP 200; no substitution was needed.