Counting & Probability

Permutations: How to Count Ordered Arrangements

The number of permutations of rr items chosen from nn different items, where order matters, is P(n,r)=n!(n−r)!P(n,r)=\dfrac{n!}{(n-r)!}. Arranging all nn items is the special case r=nr=n, which gives n!n!.

P(n,r)=n!(n−r)!P(n,r)=\frac{n!}{(n-r)!}

Try it with your numbers

Show every step

A permutation is an arrangement in which ABC and CBA count as different outcomes. The whole idea rests on the fundamental counting principle, and once you see that, the formula stops being something to memorize.

What is the permutations formula and where does it come from?

Picture rr numbered slots in a row, such as the places in a race. The first slot can be filled by any of nn items. Once one is used, the second slot has n−1n-1 choices, the third has n−2n-2, and so on until the last slot, which has n−r+1n-r+1 choices. Multiplying the choices gives the count.

P(n,r)=n(n−1)(n−2)⋯(n−r+1)=n!(n−r)!P(n,r)=n(n-1)(n-2)\cdots(n-r+1)=\frac{n!}{(n-r)!}

The factorial form is just a compact way to write that product. Multiply and divide by (n−r)!(n-r)! and the extra factors (n−r)(n−r−1)⋯1(n-r)(n-r-1)\cdots 1 are exactly what the fraction cancels. So the denominator is not a mysterious correction: it removes the arrangements of the items you never picked.

This also explains why 0!=10!=1. Arranging all nn items must give P(n,n)=n!0!P(n,n)=\frac{n!}{0!}, and that equals n!n! only if 0!=10!=1. The formula assumes order matters, no item is reused, and r≤nr\le n. Break any of those and a different formula applies, which the rest of this page covers.

How do you calculate nPr step by step?

Number line showing 336 for P(8,3) between the bounds 5 cubed and 8 cubed
Any answer for P(8,3) has to land between 5³ = 125 and 8³ = 512, and 336 does.

Skip the big factorials. Write rr factors starting at nn and count down. For P(8,3)P(8,3) that means three factors starting at 8:

P(8,3)=8×7×6=336P(8,3)=8\times 7\times 6=336

The factorial route agrees: 8!5!=40320120=336\frac{8!}{5!}=\frac{40320}{120}=336. The shortcut is the same calculation with the cancelling already done, and it avoids overflow on a calculator when nn is large. Most scientific calculators have an nPr key, and on a TI graphing calculator it sits in the MATH menu under PRB.

A quick sanity check: the answer must fall between (n−r)r(n-r)^r and nrn^r. Here 53=1255^3=125 and 83=5128^3=512, and 336336 sits between them. If your result lands outside that window, a factor is missing or extra.

Here is a second worked example. A club of 12 members elects a president, a vice president and a treasurer. The roles differ, so order matters:

P(12,3)=12×11×10=1320P(12,3)=12\times 11\times 10=1320

If the same 3 people were simply a committee with no roles, the order would vanish and the count would shrink to 13203!=220\frac{1320}{3!}=220. That is the territory of combinations, and the roles-or-no-roles question is the quickest way to tell the two apart.

Quick check

Evaluate P(7,3)P(7,3).

How do you count permutations with repeated letters?

When some items are identical, the plain formula overcounts. The fix comes from one clean idea. Pretend the identical items are secretly labelled, such as O1\text{O}_1 and O2\text{O}_2 in BOOK, and count all 4!=244!=24 arrangements. Swapping the two O’s does not produce a new word, so every real arrangement was counted 2!2! times. Divide:

4!2!=12\frac{4!}{2!}=12

For several repeated groups, divide by a factorial for each group. Take MISSISSIPPI: 11 letters, with I four times, S four times, P twice and M once.

11!4! 4! 2!=39,916,80024×24×2=39,916,8001152=34,650\frac{11!}{4!\,4!\,2!}=\frac{39{,}916{,}800}{24\times 24\times 2}=\frac{39{,}916{,}800}{1152}=34{,}650

Using 11! alone would overcount each word exactly 11521152 times. Notice that M, which appears once, contributes a factor of 1!=11!=1 and can be ignored.

Check the group sizes

The group counts in the denominator must add up to nn. For MISSISSIPPI, 1+4+4+2=111+4+4+2=11. If they do not, a letter was missed.

Which permutations formula fits the problem?

Bar comparing 10,000 PINs with repeats allowed to 5040 PINs with no repeated digits
A 4-digit PIN has 10,000 options with repeats but only 5040 without, so 4960 are lost.

Most lost points come from choosing the wrong formula, not from arithmetic. Three questions sort nearly every problem:

  1. Does order matter? If not, it is a combination, and permutations vs combinations shows how to decide.
  2. Can the same item be used again, as with digits in a PIN?
  3. Are some of the items identical, as with repeated letters in a word?
Situation Count
Choose and order rr of nn different items, no reuse n!(n−r)!\dfrac{n!}{(n-r)!}
Arrange all nn different items n!n!
Reuse allowed, rr slots nrn^r
Some items identical n!k1! k2!⋯\dfrac{n!}{k_1!\,k_2!\cdots}
Around a circle, rotations the same (n−1)!(n-1)!

Reuse allowed and identical items sound alike but are different ideas. A 4-digit PIN with repeats allowed has 104=10,00010^4=10{,}000 possibilities, because every slot has all 10 digits available. With no repeated digits it drops to P(10,4)=10×9×8×7=5040P(10,4)=10\times 9\times 8\times 7=5040. The 49604960 PINs that disappear are exactly those with at least one repeated digit.

How many circular permutations are there?

Around a round table, rotating everyone one seat produces the same arrangement. Linear counting treats those rotations as different, so it counts each seating exactly nn times. Divide by nn:

n!n=(n−1)!\frac{n!}{n}=(n-1)!

For 6 people, 6!6=7206=120\frac{6!}{6}=\frac{720}{6}=120, which equals 5!5!. Another way to see it: seat one person anywhere to fix the reference point. The other 5 then fill the remaining seats in 5!5! ways.

Two traps matter here. If the seats are numbered or distinguishable (a table with a head, or chairs with name cards), rotations are no longer identical and the answer is n!n! again. And if the circle can be flipped over, as with a bracelet or necklace of distinct beads, each arrangement and its mirror image are the same, so divide by 2 once more. Five distinct beads on a bracelet give 4!2=12\frac{4!}{2}=12 (this flip rule applies when there are at least 3 beads).

Quick check

In how many ways can 5 people sit at a round table if only their positions relative to each other matter?

How do you handle permutations with restrictions?

Restrictions break the simple product, but three tactics cover almost every case:

  • Fill the most restricted slot first, then the rest.
  • Glue items that must stay together into one block, then arrange the block internally.
  • Count everything, then subtract the forbidden cases (the complement).

Take 3-digit numbers from the digits 0 to 5 with no repeats. The first digit cannot be 0, so fill it first: 55 choices. The second slot has 55 left (0 is now allowed), and the third has 44. That gives 5×5×4=1005\times 5\times 4=100. The complement confirms it: all P(6,3)=120P(6,3)=120 arrangements, minus the P(5,2)=20P(5,2)=20 that start with 0, leaves 100100.

Try this: Seat 4 people in a row so that Dana is not in the first seat. Count it twice, once with the restricted-slot-first method and once with the complement. Both should give the same number.

Now a glued example. Five people stand in a row, and A and B must be adjacent. Treat AB as one block, so there are 4 units to arrange: 4!=244!=24. The block itself can be AB or BA: 2!=22!=2. Total: 24×2=4824\times 2=48. People who must not be adjacent are the complement: 5!−48=120−48=725!-48=120-48=72.

How do you solve for n when nPr is given?

Sometimes the answer is known and nn is missing. For P(n,2)=72P(n,2)=72, expand the product: n(n−1)=72n(n-1)=72. Rearranged, that is a quadratic:

n2−n−72=0⇒(n−9)(n+8)=0n^2-n-72=0\quad\Rightarrow\quad (n-9)(n+8)=0

So n=9n=9 or n=−8n=-8. A count of items cannot be negative, so n=9n=9. Check: 9×8=729\times 8=72. If the factoring is not obvious, the quadratic formula practice problems cover the same technique.

A faster mental method works for small rr. You are looking for rr consecutive descending whole numbers with the given product. For P(n,3)=210P(n,3)=210, think of 7×6×5=2107\times 6\times 5=210, so n=7n=7. Checking factor pairs near the cube root of the target finds the starting number quickly.

This also answers the question about negatives and fractions. Factorials are defined for whole numbers 0,1,2,…0,1,2,\dots, so nn and rr must be whole numbers with 0≤r≤n0\le r\le n. Negative or fractional values have no meaning as item counts, and a negative root of the quadratic must be discarded. When r>nr>n with no reuse, the count is 00.

How do permutations connect to combinations and probability?

Every group of rr items can be ordered in r!r! ways, so permutations are combinations multiplied by the orderings of each group:

P(n,r)=C(n,r)×r!⟺C(n,r)=P(n,r)r!P(n,r)=C(n,r)\times r!\qquad\Longleftrightarrow\qquad C(n,r)=\frac{P(n,r)}{r!}

Check with n=10n=10, r=3r=3: C(10,3)=120C(10,3)=120 and 120×6=720=10×9×8120\times 6=720=10\times 9\times 8.

Not symmetric

C(n,r)=C(n,n−r)C(n,r)=C(n,n-r), but permutations do not behave that way: P(10,3)=720P(10,3)=720 while P(10,7)=604,800P(10,7)=604{,}800.

Permutations also drive basic probability when outcomes are equally likely. Suppose 8 runners finish in a random order. Exactly one finishing order puts three named runners in gold, silver and bronze, out of P(8,3)=336P(8,3)=336 possible podiums, so the chance is 1336\frac{1}{336}. If the order among those three does not matter, 3!=63!=6 podiums qualify, giving 6336=156\frac{6}{336}=\frac{1}{56}, which equals 1C(8,3)\frac{1}{C(8,3)}. The same event, counted with or without order, gives the same probability as long as numerator and denominator use the same convention.

Quick check

Given that C(6,3)=20C(6,3)=20, find P(6,3)P(6,3) using the link between the two.

Where else do permutations show up in math?

Determinants are built from permutations. The determinant of an n×nn\times n matrix is a sum over all n!n! ways to pick one entry from each row and column, with each term given a plus or minus sign. A 2×2 matrix has 2!=22!=2 terms, which is why the 2×2 determinant is ad−bcad-bc. A 3×3 matrix has 3!=63!=6 terms, the three positive and three negative products you meet in the 3×3 determinant.

The sign of each term depends on how many pairs are out of order (inversions) in the arrangement. A fully reversed list of nn items has the most inversions, n(n−1)/2n(n-1)/2, which is the sum 1+2+⋯+(n−1)1+2+\cdots+(n-1) from the arithmetic series formula.

Factorials grow absurdly fast, so logs help you gauge size. Since a log of a product is a sum of logs (see the logarithm rules), log⁡10(20!)=∑k=120log⁡10k≈18.39\log_{10}(20!)=\sum_{k=1}^{20}\log_{10}k\approx 18.39, so 20!20! has 19 digits. A shuffled 52-card deck has about 8×10678\times 10^{67} orderings, which is why a well-shuffled deck has almost certainly never occurred before in history. The same counting underlies passwords, scheduling and cipher design.

Practice problems

0 of 5 solved

  1. Evaluate P(9,3)P(9,3).

  2. Ten runners enter a race. In how many ways can gold, silver and bronze medals be awarded (no ties)?

  3. How many different arrangements of the letters in LETTER are there?

  4. How many 3-digit even numbers can be made from the digits 1, 2, 3, 4, 5, 6 if no digit repeats?

  5. Seven people stand in a line. Ana and Ben must not stand next to each other. How many line-ups are possible?

Common questions

What is the formula for permutations?

The number of ordered arrangements of rr items chosen from nn different items is P(n,r)=n!(n−r)!P(n,r)=\frac{n!}{(n-r)!}. It is the same as multiplying rr descending factors starting at nn. Arranging all nn items gives n!n!.

What is the difference between a permutation and a combination?

A permutation counts selections where order matters, so ABC and CBA are different. A combination ignores order, so they are the same selection. Each combination of rr items corresponds to r!r! permutations, which is why C(n,r)=P(n,r)r!C(n,r)=\frac{P(n,r)}{r!}.

Why does 0! equal 1?

There is exactly one way to arrange zero items: do nothing. It also keeps the formula consistent, because arranging all nn items must give P(n,n)=n!0!=n!P(n,n)=\frac{n!}{0!}=n!, which only works if 0!=10!=1.

How do you find permutations when some letters repeat?

Count all n!n! arrangements as if every letter were different, then divide by k!k! for each group of kk identical letters. For BOOK this gives 4!2!=12\frac{4!}{2!}=12.

How many ways can n people sit around a circular table?

If only the seating relative to the others matters, there are (n−1)!(n-1)! ways, because rotating everyone gives the same arrangement. If the seats are numbered or distinguishable, the answer is n!n!.

Can r be larger than n in a permutation?

Not when items cannot be reused. You cannot fill 5 ordered slots from 3 different items, so the count is 00. If reuse is allowed, such as digits in a PIN, the count is nrn^r and rr can be as large as you like.

Up next