GenerateRandomSearch

Permutation and Combination Calculator

Permutations and combinations get confused constantly, and it is not a failure of memory — it is that the difference is a single question nobody thinks to ask. Does the order matter? A podium is a permutation, a committee is a combination, and the same six people give 120 of one and 20 of the other. This shows both at once, which is the only way the distinction stays visible.

What this generator does

Computes all four ways of counting a selection: ordered without repetition (nPr), unordered without repetition (nCr), ordered with repetition, and unordered with repetition. Each is shown with its formula, its substituted values and its exact result. Showing them together is deliberate — the four differ only by two yes-or-no questions, and seeing all four makes clear which question you have actually answered.

How to use this tool

  1. Enter how many items you have to choose from.
  2. Enter how many you are choosing.
  3. Press Calculate.
  4. Read all four counts: ordered and unordered, each with and without repetition, alongside the working.

Understanding the controls

Items to choose from (n)
The size of the pool. Growth here is dramatic: doubling n does far more than double most of these counts, which is why sizing a problem before enumerating it is worth doing.
Items being chosen (r)
How many you take. For combinations this is symmetric — choosing 3 from 10 and choosing 7 from 10 give the same count, because choosing who is in a group is the same as choosing who is out.
Repetition
Whether an item can be picked more than once. A PIN allows repetition and a lottery ticket does not, which is why a four-digit PIN has 10,000 possibilities and choosing four different digits has far fewer.

Worked examples

Six people, three prizes
Ordered: 120 ways. Unordered: 20 ways. The medals are what make it six times bigger.
A four-digit PIN
10,000 — ordered, with repetition. Four different digits gives only 5,040.
A lottery ticket
Choosing 6 from 49 unordered without repetition: 13,983,816.
A shuffled deck
52! arrangements — 68 digits, and more than the estimated number of atoms in the galaxy.

Common use cases

  • Checking homework or a formula you half-remember, with the working shown
  • Working out how many possible passwords, PINs or codes a format allows
  • Sizing a problem before writing code to enumerate it
  • Teaching the order-matters distinction using a case where both answers are on screen
  • Understanding why some counts explode and others merely grow

How this generator works

Everything is computed in arbitrary-precision integers, and the routes taken matter. nPr is built as a falling product — n x (n−1) x … — rather than as n!/(n−r)!, which would compute two enormous numbers only to divide them back down. nCr divides as it goes, which is exact at every step: after multiplying i consecutive terms the running value is always divisible by i!, so the calculation never leaves the integers. That is what allows results with dozens of digits to be shown in full, when a floating-point route would silently start rounding above about sixteen.

Randomness and fairness

Nothing is random. These are counts, computed exactly from the numbers you enter, and identical inputs always give identical results.

For how randomness is produced across the whole site, see how Generate Random works.

Assumptions this tool makes

  • Every item in the pool is distinguishable from every other. Counting arrangements of repeated identical items is a different formula.
  • A selection of r items is taken from the pool as a whole, with no groups or categories imposed on it.

Limitations and good to know

  • It counts selections from a single undifferentiated pool. Problems with grouped or constrained items — 'at least two must be from this subset' — need a different calculation this does not perform.
  • It cannot tell you which of the four counts your problem needs. That depends on whether order matters and whether repetition is allowed, and only you know the problem.
  • Very large inputs are refused rather than computed. The numbers stay exact but stop being useful long before they stop being calculable.
  • It counts possibilities, not probabilities. Turning a count into a chance needs the count of favourable cases as well, which is what the lottery calculator does.

Common mistakes

Using nPr when the order does not matter
Ask whether swapping two chosen items gives a different outcome. For a committee it does not, so it is a combination; for a podium it does, so it is a permutation. Getting this backwards inflates the answer by exactly r!.
Forgetting that repetition is allowed
Codes, PINs and dice allow repetition; dealt cards and drawn lottery balls do not. The two counts diverge quickly — for 4 from 10 it is 10,000 against 5,040.
Trusting a spreadsheet for large values
Most spreadsheet and calculator implementations move to floating point above a certain size and start returning rounded values that look exact. Anything past about sixteen digits from those tools should be treated as approximate.

Practical tips

  • Say the problem out loud with two specific items swapped. If the result is a different outcome, order matters and you want a permutation.
  • Use the symmetry of nCr to check yourself: choosing 3 from 10 must equal choosing 7 from 10, and if your working disagrees the working is wrong.
  • When sizing a brute-force search, compute the count first. A great many enumeration problems are settled by discovering the answer has thirty digits.

Troubleshooting

The result disagrees with my calculator
Check the digit count. Most calculators switch to floating point past fifteen or sixteen significant figures and show a rounded value without saying so. The result here stays exact throughout.
I do not know which of the four I need
Answer two questions in order: does swapping two chosen items change the outcome, and may an item be chosen twice. Those two answers pick one of the four uniquely.

Privacy and your data

Two numbers are entered and neither leaves your browser. Nothing is stored, nothing appears in the page address, and analytics records only that the calculator ran.

Frequently asked questions

What is the actual difference between a permutation and a combination?
Whether order matters. A permutation counts arrangements, so gold-silver-bronze awarded differently is a different permutation. A combination counts selections, so the same three people are one combination however the medals fall. Every permutation count is the combination count multiplied by r!, the number of ways to order what you chose.
Why are the results exact rather than in scientific notation?
Because the arithmetic is done in arbitrary-precision integers rather than floating point. Scientific notation would hide the fact that a double cannot represent these values exactly past 2^53, and on a page about counting that would be the one thing worth not hiding.
Is there a separate page for each of these?
No, deliberately. They are one question separated by whether order matters, and splitting them into two pages would put the answer to that question on whichever page you did not open.