Skip to content
ToolBoxGeniehome

Permutation and Combination Calculator

Calculators · Added

Choose whether order matters and whether items may repeat, enter n and r, and this calculator gives the exact count with the formula written out beneath it. The arithmetic is done in arbitrary-precision integers rather than floating point, so results stay exact well past the point where an ordinary calculator starts quietly rounding.

What to count

Order does not matter and nothing repeats — lottery draws, committees, hands of cards.

A whole number up to 1,000.

Cannot be larger than n in this mode.

How to use the permutation and combination calculator

  1. 1Pick the mode: nPr when order matters, nCr when it does not, and the repetition variants when an item may be used more than once.
  2. 2Read the sentence under the mode switch — it describes the kind of question that mode answers, which is usually quicker than recalling the definitions.
  3. 3Enter n, the number of things available, and r, the number you take.
  4. 4Press Count. The headline is the answer; the rows beneath show the general formula and the same formula with your numbers in it.
  5. 5For very large results the headline switches to scientific notation and reports how many digits the exact answer has.

Examples

A hand of cards

Input
nCr with n = 52, r = 5
Result
2,598,960

The number of distinct five-card poker hands. Order does not matter, because a hand is the same hand however it was dealt.

Podium finishes

Input
nPr with n = 8, r = 3
Result
336

Eight runners, three medals. Order matters here — gold and silver swapped is a different outcome.

A four-digit PIN

Input
Permutations with repetition, n = 10, r = 4
Result
10,000

Each of the four positions is filled independently from all ten digits, so it is 10⁴ rather than a shrinking product.

Scoops from a tub

Input
Combinations with repetition, n = 3, r = 6
Result
28

Six scoops from three flavours, repeats allowed and order irrelevant. Note that r is larger than n, which only the repetition modes permit.

About the permutation and combination calculator

The four questions this covers, and how to tell them apart

Nearly every counting problem of this shape reduces to two yes-or-no questions: does order matter, and may an item be used more than once. Answer both and the formula is determined. Order matters and no repetition gives nPr; order irrelevant and no repetition gives nCr; order matters with repetition gives nʳ; order irrelevant with repetition gives the multiset coefficient.

The mistakes are almost always in the first question rather than the arithmetic. A lock that opens with 1-2-3 but not 3-2-1 is a permutation, whatever it is called in ordinary speech. A set of lottery numbers drawn in any sequence is a combination, even though the balls come out in a definite order. It is worth deciding what would count as a different outcome before reaching for a formula.

The second question is easier but more often forgotten. Sampling with replacement — a die rolled repeatedly, a character allowed to reappear in a password — permits repetition. Dealing cards from one deck does not.

Why factorials get astronomically large so quickly

Factorial growth outpaces exponential growth, and the numbers involved defeat intuition almost immediately. There are 52! ways to shuffle a deck of cards — a number with 68 digits. Since far fewer than 10^68 shuffles have ever been performed by anyone, a properly shuffled deck has in all likelihood never previously existed in that exact order.

This is also why the formulas are never evaluated the way they are written. Computing nCr as n! divided by r!(n − r)! means building two enormous numbers and dividing most of them away again. This tool multiplies the answer up one factor at a time instead, dividing as it goes, which keeps every intermediate value near the size of the result. The answer is identical; the work is a fraction of it.

The practical consequence for anyone using a spreadsheet or a pocket calculator is worth knowing: exact integer arithmetic typically runs out at 18!, and from 19! upward the last few digits of any large count are decoration. If the exact integer matters — and in combinatorics it usually does — check what your tool is actually computing with.

Frequently asked questions

When do I use nPr and when do I use nCr?
Ask whether rearranging your choice produces a different outcome. Three people chosen for a committee are the same committee in any order, so that is nCr. The same three people chosen as chair, secretary and treasurer are three different appointments depending on who gets which, so that is nPr. The two are related by a single factor: nPr = nCr × r!, because every unordered selection of r items can be arranged in r! ways.
Why is nCr always smaller than nPr?
Because combinations collapse together every arrangement that permutations count separately. With n = 5 and r = 3 there are 60 ordered arrangements, but each group of three has 3! = 6 orderings, so there are 60 ÷ 6 = 10 distinct groups. The only case where the two agree is r = 0 or r = 1, where there is nothing to reorder.
Can r be larger than n?
Only in the repetition modes. Without repetition you are taking distinct items out of a finite set, so asking for six from three is impossible and the tool says so rather than returning zero. With repetition each pick is independent — six scoops from three flavours, or a ten-character password from a 26-letter alphabet — so r may be as large as you like.
Are the results exact for large numbers?
Yes. The counts are computed with arbitrary-precision integers, so 100C50 comes back as its full thirty-digit value rather than as a rounded approximation. This matters sooner than most people expect: 18! is the last factorial that fits exactly in an ordinary JavaScript number, and from 19! upward a conventional implementation starts returning subtly wrong digits at surprisingly modest inputs. Where a result is too long to read, the display switches to scientific notation and tells you the digit count, but the underlying value is still exact.
What is the stars-and-bars formula?
It is the reason combinations with repetition use (n + r − 1)Cr. Picture the r items you are choosing as stars in a row, and n − 1 dividers separating them into n type-groups. Every arrangement of stars and dividers corresponds to exactly one selection, so counting the selections is the same as choosing which of the n + r − 1 positions hold stars. That is why the formula counts from a total larger than n.