Formula & Calculator

Permutations

A permutation counts the number of ways to arrange r items chosen from n distinct items, where order matters. The formula is n! / (n−r)!. For example, the number of ways to arrange 3 books from 5 on a shelf is 5!/2! = 60. It is used in probability, cryptography, and scheduling. If order did not matter, you would use combinations instead.

Mathematics Combinatorics Research
VORZEP · COMBINATORICS & COUNTING TOOLS

Permutations (nPr) Calculator

Solve the classic permutation relation nPr = n! / (n − r)! for any of its three unknowns — the number of ordered arrangements, the size of the pool, or the number of positions filled — with step-by-step working, a live counting schematic, and companion combination metrics.

nPr = n! / ( n − r )!
Solve for
Permutations (nPr) The number of distinct ordered arrangements when r items are selected from a pool of n without replacement. Order matters: AB and BA count as two different permutations. Also written P(n, r), nPr or A(n, r).
ways
Permutations must be at least 1.
= 10 × 9 × 8 × 7
Total items (n) The size of the pool you are choosing from. Must be a whole number ≥ 0, and at least as large as r. Examples: 10 digits for a PIN code, 52 cards in a deck, 26 letters of the alphabet, 20 runners in a race.
items
n must be a whole number ≥ 0.
= 10! = 3,628,800
Items chosen (r) How many positions you fill from the pool. Must be a whole number with 0 ≤ r ≤ n. Choosing 4 of 10 digits for a PIN gives r = 4. When r = n you are arranging the entire pool, and nPr = n!.
slots
r must be a whole number ≥ 0.
= 4! = 24
PERMUTATIONS (nPr)
5,040 ways
n = 10 · r = 4 · nCr = 210
SMALL COUNT
nPr = n! / (n − r)!
Step-by-step solution
nPr vs. r (log scale)
n = current n − 2 n + 2
nPr vs. n (log scale)
r = current r − 1 r + 1
Sensitivity
Companion counting metrics
Ordered selection — live schematic
ORDERED SELECTION WITHOUT REPLACEMENT · nPr = n! / (n − r)! POOL order r ORDERED SLOTS count OUTCOMES 5,040 n = 10 items r = 4 slots nPr ordered ways 10P4 = 10! / (10 − 4)! = 10 × 9 × 8 × 7 = 5,040
Pool of n distinct items r ordered positions filled without replacement Total number of distinct ordered outcomes
What the permutation relation really counts
nPrordered arrangements
=
n!arrange the whole pool
/
(n − r)!arrangements of the leftovers

Order matters — that is the whole point

A permutation counts sequences, not sets. Choosing the letters A, B, C in that order is a different outcome from C, B, A. That is why nPr is always larger than the corresponding combination nCr — by exactly a factor of r!, the number of ways to reorder the r chosen items. Whenever a problem mentions positions, ranks, passwords, race finishes, batting orders, or schedules, you almost certainly want a permutation rather than a combination.

Growth is brutally fast

Each extra position multiplies the count by the next available item. Going from r to r + 1 multiplies nPr by (n − r). This is why a 4-digit PIN has 5,040 possibilities but a 6-digit PIN has 151,200, and why 20! already exceeds 2.4 quintillion — more than the number of grains of sand on Earth. Factorial growth is the reason brute-force search collapses so quickly as keys get longer.

Without replacement is the default assumption

The formula n! / (n − r)! assumes each item can be used at most once. When repetition is allowed the count becomes nr instead, which is always larger. A 4-digit PIN with repeats allowed has 10,000 codes; without repeats it has only 5,040. Getting this distinction wrong is the single most common error in counting problems, so always ask first whether an item can be reused.

It underpins probability and algorithms

Permutations are the backbone of probability (the chance of any one ordered outcome is 1 / nPr), of sorting analysis (n! possible orderings of n items sets the lower bound for comparison sorts), and of scheduling and routing. The travelling-salesman problem, job-shop scheduling, and tournament bracket generation are all, at heart, questions about permutations — and their difficulty comes directly from how fast nPr explodes.

How to Use This Calculator

The permutation relation links three quantities: nPr, n, and r. Pick which one you want the tool to solve, then fill in the other two.

1. Choose what to solve for

Pick nPr, n, or r from the toggle. The calculator rearranges nPr = n! / (n − r)! for whichever variable you choose — including the inverse searches for n and r.

2. Use realistic presets

Presets cover common cases: permutation counts from 6 to 3,628,800, pool sizes from 5 to 52 items, and selection sizes from 2 to 10 positions.

3. Remember the two hard rules

Both n and r must be whole numbers, and r can never exceed n. If r = n you are arranging the entire pool and nPr = n!. If r = 0 there is exactly one arrangement (the empty one) for any n.

4. Read the result and verdict

The result card shows the count, plus a colour-coded badge that classifies the magnitude from a handful of arrangements up to astronomically large counts that need scientific notation.

5. Check the schematic and charts

The schematic shows a pool of n items feeding r ordered slots and producing the final count. The chart plots nPr against r on a log scale for three different pool sizes.

6. Switch to Advanced for depth

Advanced mode adds a second chart of nPr against n, a sensitivity check on +1 to n and +1 to r, and companion metrics including combinations nCr, factorials, and the probability of a single arrangement.

What This Tool Offers

Built around the classic permutation relation nPr = n! / (n − r)!, the fundamental count of ordered selections without replacement.

Three-way solving

Solve for the permutation count, the pool size n, or the selection size r. The inverse searches for n and r use monotonic binary search with an exactness check.

Clean counting schematic

A pool-to-slots-to-outcomes diagram that redraws itself as you change n and r, so you can see exactly what is being counted.

Magnitude verdict

Each result is classified from a handful of arrangements, through the thousands and millions, up to counts so large they need scientific notation.

Big-number safe

Exact BigInt arithmetic is used wherever the result fits, with a smooth fallback to log-scale scientific notation for counts with hundreds of digits.

Dual comparison charts

nPr vs. r for three pool sizes, plus an advanced nPr vs. n chart for three selection sizes, both on log axes.

Reference tables

A full permutation lookup grid, a permutations-versus-combinations comparison, and a variable reference table with the standard notation.

Reference Tables & Lookups

A permutation lookup grid and a direct comparison with combinations.

Permutation lookup — nPr

n \ r0123456

Permutations vs. Combinations

Both count selections of r items from n, but permutations care about order and combinations do not. The two are linked by nPr = nCr × r!.

n, rnPr (ordered)nCr (unordered)Ratio nPr / nCr = r!Classic example

Typical Permutation Problems

Representative counting questions and the value of nPr that answers them.

ProblemnrnPrNotes
Podium finishes in a 10-runner race103720Gold, silver, bronze — order matters
4-digit PIN, no repeated digits1045,04010,000 codes if repeats allowed
Arrange all 6 books on a shelf66720nPr = n! when r = n
Two-card draw from a 52-card deck5222,652Ordered hands; 1,326 unordered
5-letter words from 26 letters, no repeats2657,893,600Repeats allowed would give 11,881,376
Batting order for 9 players99362,8809! — every player used once
Seat 8 guests in 8 numbered chairs8840,3208! seating arrangements
Pick a 3-person committee with roles2036,840Chair, secretary, treasurer

Variable Reference

SymbolMeaningTypical rangeUnits
nPrNumber of ordered arrangements1 – 10300+count (dimensionless)
nSize of the pool0 – 105items (whole number)
rNumber of positions filled0 – nslots (whole number)
nCrCombinations — same selection, order ignored1 – 10300+count (dimensionless)
n!Factorial of n1 – 10300+count (dimensionless)
r!Number of orderings of r items1 – 10300+count (dimensionless)

What Does nPr = n! / (n − r)! Measure?

A permutation is an ordered selection. If you have n distinct items and you fill r distinct positions with them, without ever using the same item twice, the number of possible outcomes is nPr. The formula divides n! — the number of ways to line up all n items — by (n − r)! — the number of ways to line up the items you did not choose, which are irrelevant because they never appear.

The word "ordered" is doing all the work here. If the positions were indistinguishable — a committee rather than a podium, a hand of cards rather than a sequence of draws — the answer would be the combination nCr, which is exactly r! times smaller.

Permutation Formula

The defining relationship is:

nPr = n! / ( n − r )!

Because the (n − r)! cancels, the same value can be written as a falling product of r terms:

nPr = n × (n − 1) × (n − 2) × … × (n − r + 1)

Rearranged to solve for the other two unknowns:

n = the value satisfying n × (n − 1) × … × (n − r + 1) = nPr
r = the number of factors needed to reach nPr from n

When r = n the denominator becomes 0! = 1 and nPn = n!, the number of ways to arrange the entire pool.

Permutation Variables

SymbolMeaningNotes
nTotal items in the poolWhole number ≥ 0; must be ≥ r
rItems selected and orderedWhole number with 0 ≤ r ≤ n
nPrNumber of ordered arrangementsAlso written P(n, r) or A(n, r)
nCrNumber of unordered selectionsEquals nPr / r!
nrOrdered arrangements with repetitionAlways ≥ nPr

How Each Variable Affects the Count

Adding one more item to the pool does not simply add a fixed number of outcomes — it multiplies the count. Going from n to n + 1 while holding r fixed multiplies nPr by (n + 1) / (n + 1 − r). For a large pool and a small r this is close to a factor of 1 + r/n; for a small pool and a large r it can be dramatic.

Increasing r has an even sharper effect, because each extra position adds another multiplicative factor of roughly (n − r). This is the mathematical reason passwords get disproportionately safer as they get longer, why exhaustive search over orderings is hopeless beyond about 15 items, and why the lower bound on comparison sorting is n log n rather than n! — we cannot afford to enumerate the permutations, only to reason about them.

Permutation Calculation Examples

Given: n = 10, r = 4 — solve for nPr
10P4 = 10! / 6! = 10 × 9 × 8 × 7 = 5,040
Given: nPr = 5,040, r = 4 — solve for n
n(n−1)(n−2)(n−3) = 5,040 → n = 10
Given: nPr = 5,040, n = 10 — solve for r
10 × 9 × 8 × 7 = 5,040 after four factors → r = 4
Given: n = 6, r = 6 — arrange the whole pool
6P6 = 6! / 0! = 720 = 6!
Given: n = 52, r = 5 — a 5-card ordered deal
52P5 = 52 × 51 × 50 × 49 × 48 = 311,875,200

Frequently Asked Questions

Both count ways of selecting r items from a pool of n, but nPr treats different orders as different outcomes and nCr does not. If you are filling a podium, a password, a batting order, or any set of labelled positions, you want nPr. If you are forming a committee, a hand of cards, or any group where the members are interchangeable, you want nCr. The two are related by nPr = nCr × r!, so the permutation count is always the larger of the two, larger by exactly the number of ways the chosen items can be reordered among themselves. For 10 items choosing 4, nPr = 5,040 while nCr = 210, and the ratio is 4! = 24.

Whenever repetition is allowed. The permutation formula n! / (n − r)! assumes that once an item is used it is removed from the pool — dealing cards, seating people, assigning distinct labels. If an item may be reused, each of the r positions has all n choices independently, giving nr outcomes. A 4-digit PIN allows repeated digits, so there are 104 = 10,000 codes; if repeats were forbidden there would be only 10P4 = 5,040. Always check whether the problem says "without replacement" — if it does not, think carefully about which model fits the real-world situation.

Because there is exactly one way to arrange nothing: do nothing. This is not just a convention — it is forced by consistency. The recurrence n! = n × (n − 1)! requires 1! = 1 × 0!, and since 1! = 1 we need 0! = 1. It also makes the permutation formula behave correctly at the edges: nPn = n! / 0! = n!, and nP0 = n! / n! = 1, both of which match intuition. Without 0! = 1, arranging an entire pool or choosing nothing at all would both break.

No. If you have only 5 items you cannot fill 7 distinct positions without reusing an item, and the permutation formula explicitly assumes no reuse. Mathematically, (n − r)! would require a factorial of a negative number, which is undefined in the ordinary sense (it involves the gamma function and poles). This calculator validates the constraint and will flag an error if you enter r > n. If you genuinely need to fill more positions than you have items, you are looking at permutations with repetition, and the answer is nr rather than nPr.

Enormous. 20! is about 2.43 × 1018, 52! — the number of ways to shuffle a deck of cards — is about 8.07 × 1067, and 100! has 158 digits. Double-precision floating point runs out around 170!, and even the exact integer arithmetic used here falls back to log-scale scientific notation once the count passes a few hundred digits. This calculator computes exactly with arbitrary-precision integers whenever the result fits within a reasonable size, and switches smoothly to scientific notation beyond that, so you always get a meaningful answer rather than an overflow.

Both nPr as a function of n (with r fixed) and as a function of r (with n fixed) are strictly increasing, so the calculator uses binary search. For a given target count, it narrows the range of candidate values using a log-scale comparison, then checks the few candidates nearest the boundary for an exact match. If the target does not correspond to any whole-number solution — for example asking for 1,000 permutations with r = 3, which falls between n = 10 and n = 11 — the tool reports the closest values and warns that no exact solution exists.

Anywhere order matters. Password and PIN strength analysis, lottery and card-game probability, race and tournament result counting, scheduling and rostering, routing and the travelling-salesman problem, genetics (gene ordering), cryptography (permutation ciphers and key spaces), and computer science generally — the n! orderings of n items set the lower bound for comparison sorting, and permutation enumeration underlies backtracking algorithms. Even the "how many ways can I arrange my playlist" question is a permutation problem, and the answer is almost always larger than people expect.

Calculating...

Variables

Symbol Quantity Unit
nPr Number of permutations
n Total number of distinct items
r Number of items being arranged

What it means

The number of permutations (ordered arrangements) of r objects selected from a set of n distinct objects is nPr = n!/(n−r)!. This counts the number of sequences, where order matters. It is used in problems involving passwords, race results, seating arrangements, and in algorithm analysis (e.g., number of possible states). In probability, permutations are used to calculate the number of favourable outcomes. Understanding permutations is foundational for combinatorics and discrete mathematics, with applications in computer science, cryptography, and operations research.

Worked example

Permutations – Two Examples

Real‑World
Scenario: How many ways to arrange 3 books from 5 on a shelf? Order matters.
ParameterValue
n5
r3
1₅P₃ = 5!/(5−3)! = 120/2 = 60
Result 60 ✓ Arrangements
Scenario: A race has 8 runners. How many ways to award gold, silver, bronze?
ParameterValue
n8
r3
1₈P₃ = 8!/5! = 8·7·6 = 336
Result 336 ✓ Podium outcomes
Insight: Order matters – arrangement of distinct items. Use nPr = n!/(n−r)!.

Common mistakes

  • Permutations: nPr = n!/(n−r)! – order matters.
  • If r > n: The result is 0 (or undefined).
  • n!: Factorial of n – ensure n is a non‑negative integer.
  • Applications: Used in counting arrangements, seating, and sequences.
  • Check: For small numbers, verify manually.

Applications

Permutations, nPr = n!/(n−r)!, give the number of ordered arrangements of r items from a set of n. This is fundamental in combinatorics and probability. Engineers use it in scheduling, resource assignment, and cryptography. In operations research, it helps in sequencing and routing problems. In computer science, it appears in algorithm analysis and graph problems. By calculating permutations, professionals can quantify the number of possible orders, which is essential for optimisation, risk assessment, and decision‑making in diverse fields such as logistics, software testing, and game theory.

  • Task scheduling and assignment problems
  • Cryptography – key space and password strength
  • Production sequencing and route planning
  • Probability calculations in games and betting
  • Combinatorial optimisation and search algorithms