Permutation & Combination Calculator (nPr and nCr)
Count arrangements (order matters) and selections (order does not) — with or without repetition. Results are exact integers, however large, with the factorial cancellation shown step by step.
Written by Suhaib Hassan. The counting formulas are standard and each example is re-derived by hand. Our methodology.
It uses arbitrary-precision integer arithmetic, multiplying only the factors that do not cancel, so no rounding or overflow occurs even when n is in the hundreds.
Picking the wrong formula is the usual mistake. A decision guide and a side-by-side count of all four cases help you choose correctly.
—
Numerator
Orderings of r items
Cancelled factors
Permutation vs combination: does order matter?
A permutation counts each different ordering separately. A combination treats orderings of the same items as one selection, so every combination corresponds to r! permutations.
Permutations order matters
Three tokens A, B, C can be arranged in 3! = 6 different orders:
Each ordered arrangement is a separate outcome — like the gold, silver and bronze places in a race.
Combinations order does not matter
All six orders contain the same three tokens, so they collapse into a single combination:
C(n, r) = P(n, r) ÷ r! — like choosing a committee, where only membership counts.
Step-by-step working
—
The four counting formulas
Combinations no repetition
Unordered selections where each element can be picked at most once.
Permutations no repetition
Ordered arrangements without reuse: n choices, then n − 1, and so on.
Combinations with repetition
Multisets of size r from n types (the “stars and bars” count), where items may repeat and order is ignored.
Permutations with repetition
Ordered sequences where each of the r positions can independently be any of the n symbols.
When does order matter?
A quick guide to choosing the right formula. All counts are exact.
| Scenario | Order matters? | Formula | Setup | Exact result |
|---|---|---|---|---|
| Locker padlock, distinct numbers | Yes | P(n, r) | 3 different numbers from 0–39 | 59,280 |
| Lottery, pick 6 | No | C(n, r) | 6 from 49 | 13,983,816 |
| Race podium | Yes | P(n, r) | Top 3 of 8 sprinters | 336 |
| Pizza toppings | No | C(n, r) | 3 toppings from 10 | 120 |
| Password, characters may repeat | Yes | nʳ | 62 characters, 8 slots | 218,340,105,584,896 |
Worked examples
Password key space
An 8-character password from 26 lowercase + 26 uppercase + 10 digits (62 symbols), repetition allowed.
log₂ = 8 × 5.954 ≈ 47.6 bits
Choosing a trial group
Select 20 participants from a pool of 100, order irrelevant.
≈ 5.36 × 10²⁰ possible groups
Mesh network links
How many point-to-point links join 24 servers so that every pair is connected?
What are permutations and combinations?
Permutations and combinations count the ways to select items from a set. A permutation is an ordered arrangement; a combination is an unordered selection. The factorial n! = n × (n − 1) × … × 1 underlies both, with 0! defined as 1.
How to choose the formula
- Does the order of the chosen items create a different outcome? If yes, use permutations; if no, use combinations.
- Can the same item be chosen more than once? If yes, use the “with repetition” formulas.
By Suhaib Hassan · Reviewed 28 September 2026 · How CalculatePilot verifies formulas →
Sources
- NIST Digital Library of Mathematical Functions, section 26.3 (Lattice paths: binomial coefficients) and chapter 26, Combinatorial Analysis.
- Knuth, D. E. (1997). The Art of Computer Programming, Volume 1: Fundamental Algorithms, 3rd ed. Addison-Wesley.
- ISO 80000-2:2019, Quantities and units — Part 2: Mathematics (notation for factorials and binomial coefficients).
Frequently asked questions
What is the difference between a permutation and a combination?
A permutation counts ordered arrangements, so (1, 2, 3) and (3, 2, 1) are different. A combination counts unordered selections, so they are the same. Because each combination of size r can be arranged in r! ways, the number of permutations is always r! times the number of combinations.
Why is a “combination lock” really a permutation lock?
Because the order in which you enter the digits matters: 1-2-3 opens it but 3-2-1 does not. Strictly it is a count of ordered sequences, so it uses permutation formulas (with repetition if digits can be reused).
How does this calculator handle very large factorials?
It uses arbitrary-precision integer arithmetic, so results are exact rather than rounded to floating-point. Numbers with more than 18 digits are shown in scientific notation, and “Copy exact value” copies every digit.
What are “stars and bars”?
It is a method for counting combinations with repetition. Choosing r items from n types, with repeats allowed and order ignored, is equivalent to placing r stars and n − 1 bars in a row, which gives C(n + r − 1, r).
What is 0! and what if r = 0?
By definition 0! = 1. Choosing zero items can be done in exactly one way, so C(n, 0) = P(n, 0) = 1, and n⁰ = 1.
Why can r not exceed n without repetition?
You cannot pick more distinct items than exist, so the count is 0. The calculator asks you to enter r ≤ n for the no-repetition formulas; with repetition allowed, r may be larger than n.
Related calculators
Continue with probability and factorials.