MathsDiscrete Math

Permutation
calculator.

Count the ways to put r of n things in order, or to rearrange the letters of a word.

How it's worked out

A permutation is an arrangement where order matters. Ann first and Ben second is a different result from Ben first and Ann second. The first place can take any of the n items, the second any of the n − 1 left, and so on until r places are filled. Multiplying those choices is the fundamental counting principle.

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

Here n!n!, read n factorial, means n times every whole number below it, down to 1. The bottom of the fraction cancels everything after the r-th factor, so you only multiply r numbers. When r equals n you get n!n!, every order of all the items. When r is larger than n the answer is 0, because a place would have to reuse an item. For example, P(3, 5) is 0.

Ordered against unordered. Every group of r items can be put in order in r factorial ways. So the ordered count is r factorial times the number of unordered groups, C(n, r). The tool uses that fact as the check in its working.

P(n,r)\displaystyle P(n, r)=r!C(n,r)\displaystyle {}= r!\,C(n, r)

Letters that repeat. A word with n letters has n factorial orders if every letter is treated as different. Swapping two copies of the same letter gives the same word, so each letter that appears k times divides the count by k!k!.

n!n1!n2!⋯nk!\frac{n!}{n_1!\,n_2!\cdots n_k!}

Worked examples

Coach Rivera ranks the top three of eight runners

Eight runners race for gold, silver and bronze. Gold can go to any of 8, silver to any of the 7 left, and bronze to any of the 6 after that. That gives 336 different podiums.

If the coach only cared which three runners made the podium, there would be 56 groups. Each group can stand in 6 orders, which is why the ordered count is 6 times larger.

Open this example in the tool

Priya sets a 4-digit code with no repeated digit

A keypad has 10 digits and the code uses 4 of them, each at most once. Order matters, since 1234 and 4321 are different codes. So there are 5,040 codes.

If digits may repeat, each of the 4 places has all 10 digits, which gives 10,000. Banning repeats keeps 5,040 of those 10,000 codes, about half.

Open this example in the tool

How many ways to rearrange BOOKKEEPER?

BOOKKEEPER has 10 letters. E appears 3 times, while O and K each appear twice. Treating every letter as different gives 10 factorial orders, 3,628,800 of them.

10!3!2!2!\frac{10!}{3!\,2!\,2!}

Dividing out the swaps of identical letters leaves 151,200 different strings. The check places the letters one group at a time: the three E's go into 120 possible sets of spots, then the rest follow, and the product is 151,200 again.

Open this example in the tool

Reading your result

Round tables lose one factor. Around a circle, turning everyone one seat gives the same seating. So n people around a table/07%3A_Sets_and_Counting/7.04%3A_Circular_Permutations_and_Permutations_with_Similar_Elements) have the factorial of n − 1 seatings, not n!n!. Six guests can sit in a row in 720 orders but around a table in only 120.

The numbers get large. A deck of 52 cards can be shuffled into 52 factorial orders. That is a 68-digit number, and the tool keeps every digit, so you can divide or compare it exactly.

Big counts are still exact. OpenStax counts the letters of DISTINCT, with I and T each twice, as 8 factorial divided by 2 factorial twice. The tool gives the same 10,080, and for BANANA, with three A's and two N's, it gives 60.

Common mistakes

  • Using a permutation for a committee. If swapping two chosen people changes nothing, order does not matter and you want C(n, r). Roles such as president and treasurer make order matter again.
  • Forgetting that repeats change the formula. P(n, r) uses each item at most once. A PIN that may reuse digits has nʳ codes instead.
  • Dividing for repeated letters when there are none. Only letters that appear more than once divide the count. A letter that appears once divides by 1 factorial, which is 1 and changes nothing.
  • Treating a round table like a row. Counting n factorial orders for a circle counts every seating n times, once for each turn of the table.

Questions people ask

Ask whether swapping two of the chosen items gives a different outcome. Rankings, codes and named roles change, so they are permutations. A hand of cards or a team without roles does not change, so it is a combination, and its count is smaller by a factor of r factorial.

Sources