Arithmetic, Algebra & Number Theory Sequences, Series & Combinatorics Permutations, arrangements of a multiset

Permutation Calculator (nPr)

A permutation counts ordered arrangements. Gold, silver and bronze from eight runners is a permutation; a three-person committee from the same eight is not. This calculator handles the three cases that cover almost every real problem: choosing r items from n where nothing repeats, P(n, r) = n!/(n − r)!; choosing where items may repeat, nr; and arranging a pool that already contains duplicates — the letters of a word, for instance — with the multiset formula. It also shows the matching unordered count so you can see exactly how much the ordering multiplies your answer.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
What you are countingPick the first for race placings or seat assignments, the second for PINs and passwords, the third for anagrams of a word with repeated letters.Pick r from n, no repeats — P(n, r)
Total items available (n)How many distinct things you can draw from — runners, digits, letters of an alphabet.10
Positions to fill (r)How many ordered slots there are. Without repeats this cannot exceed n; with repeats it can.3
Word or list to arrangeType the characters you want arranged; spaces, commas, hyphens and underscores are ignored and case does not matter.MISSISSIPPI

It returns

  • Number of arrangements — Distinct ordered outcomes.
  • Same selections ignoring order — The unordered count for the same problem. Arranging a fixed multiset gives 1, because there is only one such selection.
  • Ordered outcomes per unordered selection — Arrangements divided by selections. It equals r! when nothing repeats.
  • Chance of hitting one exact order — One named arrangement out of all of them, assuming every arrangement is equally likely.

The formula

P(n,r)=n!(nr)!
arrangements=nr
arrangements=n!n1!n2!nk!

In plain text: P(n, r) = n! / (n − r)!

  • P(n, r)Number of ordered arrangements of r items chosen from n (count)
  • nTotal distinct items available (count)
  • rNumber of ordered positions to fill (count)
  • nₖHow many times character k repeats, used in the multiset formula (count)

P(n, n) = n! because 0! = 1. When repetition is allowed the count is n^r instead, since every position is filled independently.

Updated Category Sequences, Series & Combinatorics Verified against published test cases Reading time 11 min

What a permutation counts

A permutation is an arrangement in which position carries meaning. Swap two items and you have a different outcome. That single test decides whether this calculator or the combination calculator is the right tool, and it is worth applying deliberately rather than by feel.

Ordering matters in more places than people expect. A race result, a batting order, a PIN, a password, a seating plan, a playlist, the order in which servers are patched, the sequence of a DNA fragment, the schedule of jobs on a machine — all of these are permutations. Ordering does not matter for a committee, a hand of cards, a lottery ticket, a pizza's toppings or a set of test cases.

The relationship between the two counts is exact rather than approximate. Any set of r distinct items can be written down in r! orders, so P(n, r) = C(n, r) × r!. With r = 1 the two counts are equal; for every r of 2 or more the permutation count is the larger, and the gap widens fast — at r = 5 it is a factor of 120. This calculator prints both figures and their ratio so the relationship is visible in your own numbers.

The three formulas, and how to tell which one you need

Ordered, no repeats: P(n, r) = n! ÷ (n − r)!. You have n options for the first position, n − 1 for the second because one item is now used, and so on down to nr + 1 for the last. Multiplying that falling chain gives the answer; writing it as a ratio of factorials is just shorthand for the same product with the unused tail cancelled. This is the case for race placings, seat assignments and any draw without replacement.

Ordered, repeats allowed: nr. Now every position is filled independently, so each of the r slots has the full n choices. A four-digit PIN is 104 = 10,000; an eight-character password from 62 alphanumerics is 628 ≈ 2.18 × 1014. Notice that r may exceed n here without any difficulty.

Arranging a multiset: n! ÷ (n₁! n₂! … nk!). Use this when the pool itself contains duplicates and you are arranging all of it. Pretend the duplicates are distinguishable and you get n! arrangements, but each genuine arrangement has been counted once for every way of permuting the identical copies among themselves — n₁! ways for the first repeated character, n₂! for the second, and so on. Dividing removes the double counting. This is the anagram formula, and it is also how you count paths on a grid: the number of shortest routes across a 4-by-3 block is 7!/(4!3!) = 35.

All three are the same idea seen from different angles: count as if everything were distinguishable, then divide out whatever you over-counted. The factorial calculator handles the raw factorials if you want to see them, though this page never computes n! directly — it multiplies the falling chain, which stays exact much longer.

Worked example: a podium, a PIN, and MISSISSIPPI

1. Eight runners, three medals. The gold, silver and bronze positions are distinct, and no runner takes two medals, so this is P(8, 3).

  1. Eight candidates for gold.
  2. Seven remain for silver.
  3. Six remain for bronze.
  4. 8 × 7 × 6 = 336 possible podiums.

The unordered count is C(8, 3) = 56, and 336 ÷ 56 = 6 = 3! — the six ways to shuffle any three medallists between the three steps.

2. A three-digit PIN. Each of the three positions may be any of the ten digits, independently, so the count is 10 × 10 × 10 = 1,000, from 000 to 999. Guessing one specific PIN at random succeeds with probability 1 ÷ 1000 = 0.1%.

3. The letters of MISSISSIPPI. There are 11 letters: one M, four I's, four S's and two P's.

  1. Total if every letter were distinct. 11! = 39,916,800.
  2. Divide out the repeats. 1! × 4! × 4! × 2! = 1 × 24 × 24 × 2 = 1,152.
  3. Divide. 39,916,800 ÷ 1,152 = 34,650 distinct arrangements.

Check the size: 34,650 is only about one arrangement in 1,152 of the naive total, which is exactly the factor you divided by. Type any word into the multiset mode and the calculator lists each repeated character and the factorial it contributes.

How to read the result

Turn the count into a probability when what you care about is a guess. One named arrangement out of P has probability 1 ÷ P, which is the percentage this calculator reports. A three-digit PIN gives 0.1% per guess; a six-digit PIN gives 0.0001%; an eight-character password drawn from 62 symbols gives about 4.6 × 10−13%. Those numbers are why length beats complexity in password policy: adding one character multiplies the space by the alphabet size, while enlarging the alphabet only raises a fixed exponent.

Read the ordered-per-unordered ratio when you are checking your own reasoning. If you expected order not to matter and the ratio comes back as 120, you have chosen the wrong mode — that factor of 120 is 5! and it means the calculator counted five positions as distinguishable. This is the single most common error in counting problems, and the ratio makes it visible.

Watch the scale. P(n, r) grows enormously in r and modestly in n: going from 10 items to 20 at r = 3 multiplies the count by about nine and a half, from 720 to 6,840, while going from r = 3 to r = 6 with n = 20 multiplies it by nearly eight thousand. When a count passes roughly 1015 the calculator switches to scientific notation, because no exact integer of that size fits in a browser number.

Finally, be clear about what the count includes. P(n, r) treats every item as distinguishable and every position as labelled. If your positions are actually interchangeable — dealing hands rather than seating guests — divide by the arrangements of the positions too, or ask the combination calculator instead.

Ordered arrangements P(n, r) for common sizes

P(n, r) = n × (n−1) × … × (n−r+1), the number of ways to fill r ordered positions from n distinct items.
nr = 2r = 3r = 4r = 5
52060120120
630120360720
8563361,6806,720
10907205,04030,240
121321,32011,88095,040
203806,840116,2801,860,480

The n = 5 row shows why P(n, n) = P(n, n−1): once four of five positions are filled, the fifth is forced, so no new arrangements appear.

Mistakes that give the wrong arrangement count

  • Using a permutation for an unordered problem. A five-card hand is C(52, 5) = 2,598,960, not P(52, 5) = 311,875,200. The permutation count is 120 times too large because it counts every deal order separately.
  • Forgetting to divide out repeated items. LEVEL has 5 letters but only 5!/(2!·2!) = 30 distinct arrangements, not 120. Any pool with duplicates needs the multiset formula.
  • Applying P(n, r) when items can repeat. A three-letter code from 26 letters is 26³ = 17,576 if letters may repeat, and P(26, 3) = 15,600 if they may not. Read the problem for the words "may repeat" or "without replacement".
  • Treating circular arrangements as linear. Seating n people around a round table gives (n − 1)! arrangements, not n!, because rotating everyone one seat produces the same seating. Divide by n when only the relative order matters.
  • Mixing up positions and items. In P(n, r), n is the pool and r is the number of slots. Entering them the wrong way round gives an answer that is often plausible but always wrong.
  • Ignoring that r may exceed n only with repetition. Ten ordered draws from six items is 0 without repeats and 610 = 60,466,176 with them.
  • Assuming every arrangement is equally likely. The count is correct regardless, but the probability reading assumes uniformity. A shuffle that is not truly random invalidates the odds without changing the count.

Several variations come up so often that they deserve their own formulas, all of them adjustments to the counts above.

Circular permutations. Around a table only relative order matters, so fix one person and arrange the rest: (n − 1)! arrangements. If the table can also be flipped over — a bracelet rather than a dinner — divide again by 2 to get (n − 1)!/2.

Arrangements with items kept together. Glue the block together and treat it as one item. Six books with three specific volumes side by side gives 4! arrangements of the blocks times 3! internal orders = 144.

Derangements. Arrangements in which nothing sits in its own place. The count is n! multiplied by the alternating sum 1 − 1/1! + 1/2! − 1/3! + …, which converges so quickly that the answer is the nearest whole number to n!/e for every n above 2. For n = 5 the derangement count is 44.

Sampling and probability. Once you have a count, the probability work usually moves elsewhere. For the chance of a specific outcome in repeated independent trials use the binomial distribution calculator; for the chance that at least one of several attempts succeeds — the birthday problem is exactly this — use the at-least-one probability calculator; and for general event arithmetic the probability calculator covers unions, intersections and complements.

Key terms

Permutation
An ordered arrangement of items. P(n, r), nPr, or (n)ᵣ all mean the number of ways to fill r ordered positions from n distinct items.
Multiset
A collection in which an item may appear more than once. Arranging one uses n! divided by the factorial of each repeat count.
With replacement
Each draw is returned before the next, so items can repeat and the count is n^r. Without replacement gives P(n, r).
Falling factorial
The product n(n−1)…(n−r+1). It is P(n, r) written without factorials, and it is how this calculator actually computes the result.
Circular permutation
An arrangement around a closed loop, where rotations are considered identical. There are (n − 1)! of them.
Derangement
A permutation that leaves no item in its original position. The count is the nearest whole number to n!/e for n ≥ 3.

Frequently asked questions

What is the difference between nPr and nCr?

nPr counts ordered arrangements and nCr counts unordered selections, and they are linked exactly by nPr = nCr × r!. Choosing three of ten people gives nCr = 120 possible groups but nPr = 720 possible orderings of those groups, a factor of 3! = 6. If rearranging the chosen items produces a genuinely different outcome, you want nPr.

How do I calculate nPr on a calculator?

Enter n, press the nPr key, enter r, then equals. On a TI-83/84 it is MATH → PRB → nPr; on Casio models it is usually OPTN → PROB → nPr. In a spreadsheet use =PERMUT(10,3), which returns 720, or =PERMUTATIONA(10,3) for the repeats-allowed version, which returns 1000.

How many ways can the letters of a word be arranged?

Take the factorial of the length and divide by the factorial of each letter's repeat count. BANANA has 6 letters with three A's and two N's, so 6!/(3!·2!·1!) = 720/12 = 60 arrangements. A word with no repeated letters is simply the factorial of its length: DOG gives 3! = 6. Switch this calculator to its multiset mode and type the word to see the repeat counts listed.

Why is P(n, n) equal to n! and not 1?

Because arranging all n items still leaves n! different orders. The formula gives n!/(n − n)! = n!/0!, and since 0! = 1 that is n!. It also explains the identity P(n, n) = P(n, n−1): after placing n − 1 items there is only one item left and only one place to put it, so the last step adds no new arrangements.

Can r be greater than n?

Only in the repeats-allowed mode. Without repetition you run out of distinct items, so the count is exactly zero and the calculator says so. With repetition there is no constraint at all: ten ordered draws from six items is 610 = 60,466,176, because each draw is independent of the last.

How many possible passwords are there?

Alphabet size raised to the length. Six lowercase letters gives 266 = 308,915,776; eight characters from the 62 letters and digits gives 628 ≈ 2.18 × 1014; twelve gives about 3.23 × 1021. Each extra character multiplies the space by the alphabet size, which is why length is the dominant factor. Use the repeats-allowed mode with n as the alphabet size and r as the length.

What is a normal size for a permutation problem?

Hand-worked problems almost always keep r at 5 or fewer, because the chain of multiplications stays short. Applied problems run much larger: a 52-card shuffle has 52! ≈ 8.07 × 1067 orderings, more than the estimated number of atoms in our galaxy. Once the count passes about 1015 its exact digits stop being useful and the order of magnitude is the number to quote.

Do circular arrangements use the same formula?

No — divide by n. Seating n people around a round table gives (n − 1)! arrangements rather than n!, because rotating everybody by one seat produces the same arrangement of neighbours. Five people around a table therefore have 4! = 24 distinct seatings, not 120. If reflections also count as identical, as with a bracelet, divide by 2 again.

References