Math · Live
Permutation & Combination Calculator —
nPr and nCr with full working.
Enter n (total items) and r (items selected) to instantly compute P(n, r) permutations and C(n, r) combinations, with step-by-step formula working, exact integer results using BigInt arithmetic, and a Pascal's triangle context row.
Inputs
P(n, r) and C(n, r)
Formulas
P(n, r) = n! / (n − r)!
C(n, r) = n! / [r! × (n − r)!]
P(n, r) = r! × C(n, r)
- P(n, r)
- 336
- C(n, r)
- 56
- r!
- 6
Permutations
P(8, 3) — order matters
Combinations
C(8, 3) — order doesn't matter
Relationship
Permutations = r! × Combinations
P(8, 3) = 3! × C(8, 3)
336 = 6 × 56
Every combination of 3 items can be arranged in 3! = 6 different orders. Multiplying the combinations by r! gives the total number of ordered arrangements.
Working
P(8, 3) — full working
- 1Formula
P(n, r) = n! / (n − r)!
- 2Substitute
P(8, 3) = 8! / (8 − 3)! = 8! / 5!
- 3Cancel (n−r)! from numerator and denominator
P(8, 3) = 8 × 7 × 6
- 4Compute
P(8, 3) = 336
Working
C(8, 3) — full working
- 1Formula
C(n, r) = n! / [r! × (n − r)!]
- 2Substitute
C(8, 3) = 8! / [3! × (8 − 3)!] = 8! / [3! × 5!]
- 3Cancel (n−r)! from top and bottom, expand r!
C(8, 3) = (8 × 7 × 6) / (3 × 2 × 1)
- 4Divide P(n,r) by r!
C(8, 3) = P(8,3) / 3! = 336 / 6
- 5Result
C(8, 3) = 56
Context
Row 8 of Pascal's triangleC(8, k) for each k
C(8,0)
1
C(8,1)
8
C(8,2)
28
C(8,3)
56
C(8,4)
70
C(8,5)
56
C(8,6)
28
C(8,7)
8
C(8,8)
1
Field guide
Permutations and combinations explained.
Permutations and combinations both count the ways to select items from a set, but they ask different questions. Permutations count the number of ways to arrange r items chosen from n distinct items, where the order of selection matters. Combinations count the number of ways to choose r items from n, where order is irrelevant.
The classic memory aid: if you are picking a 3-digit lock code from digits 1–9 and no digit repeats, order matters (1-2-3 is different from 3-2-1). That is a permutation. If you are choosing 3 students from a class of 9 for a committee, order doesn't matter (selecting Alice, Bob, Carol is the same as Carol, Alice, Bob). That is a combination.
The formulas
P(n, r) = n! / (n − r)!
= n × (n−1) × (n−2) × ⋯ × (n−r+1) [r multiplied terms]
C(n, r) = n! / [r! × (n − r)!]
= P(n, r) / r! [divide out the duplicate orderings]
In both formulas, n! (n factorial) denotes the product 1 × 2 × 3 × ⋯ × n. The convention 0! = 1 ensures P(n, 0) = C(n, 0) = 1 ; there is exactly one way to arrange or choose zero items (do nothing).
Why is P(n, r) = r! × C(n, r)?
Every combination of r items can be rearranged in r! different orders. If there are C(n, r) unique groups, and each group has r! orderings, then the total number of ordered arrangements is C(n, r) × r! = P(n, r). This identity is one of the most elegant results in elementary combinatorics — permutations and combinations are not separate concepts but the same concept at two levels of granularity.
Worked example: a 4-digit PIN
How many 4-digit PINs can be formed from the digits 0–9 without repeating any digit?
- n = 10 (digits 0–9), r = 4 (PIN has 4 digits)
- Order matters (1234 ≠ 4321), so we use permutations
- P(10, 4) = 10 × 9 × 8 × 7 = 5,040
How many 4-person committees can be chosen from the same group of 10 people?
- n = 10, r = 4; order doesn't matter → combinations
- C(10, 4) = 5040 / 4! = 5040 / 24 = 210
Permutations with and without repetition
The formula P(n, r) = n! / (n − r)! counts permutations without repetition (each item can be used at most once). When repetition is allowed, for example, a 4-digit PIN where the same digit can appear multiple times — the count is simply n^r (10^4 = 10,000 PINs).
Similarly, combinations without repetition are given by C(n, r) above. Combinations with repetition (multisets) use the formula C(n + r − 1, r), also written H(n, r).
Pascal's triangle and combinations
Pascal's triangle is a triangular array where each row n lists the binomial coefficients C(n, 0), C(n, 1), …, C(n, n). These are exactly the combination values, the number of ways to choose k items from n for every k from 0 to n. The defining recurrence is:
C(n, k) = C(n−1, k−1) + C(n−1, k)
Each entry is the sum of the two entries directly above it.
This recurrence is how Pascal's triangle is constructed row by row. The binomial theorem uses these coefficients to expand (a + b)^n, hence the name “binomial coefficients” for C(n, k).
Common applications
| Application | Type | Formula |
|---|---|---|
| Lock / PIN codes (no repeats) | Permutation | P(n, r) |
| Race finishing orders | Permutation | P(n, r) |
| Seating arrangements | Permutation | P(n, r) |
| Lottery (choose r from n balls) | Combination | C(n, r) |
| Committee selection | Combination | C(n, r) |
| Choosing pizza toppings | Combination | C(n, r) |
| Binomial distribution P(X = k) | Combination | C(n, k) |
| Probability of hands in poker | Combination | C(52, 5) |
How this calculator handles large numbers
Standard 64-bit floating-point arithmetic (JavaScript's number type) can only represent integers exactly up to 2^53 − 1 ≈ 9 × 10^15. Beyond that, rounding errors creep in — P(30, 15) has 17 digits and would silently lose precision with ordinary arithmetic.
This calculator uses BigInt, JavaScript's arbitrary- precision integer type, for all factorial and combinatorial arithmetic. Every result shown is the exact integer value regardless of how many digits it has — results too long to display in full are shown in scientific notation with the exact digit count reported.