Permutation and Combination Calculator (nPr and nCr)

  • Free
  • No sign-up
  • Works on phones
  • Shows the working
Geometry & Stats#71

Permutations & Combinations

\(P(n, r)\) and \(\binom{n}{r}\), exactly, plus the versions with repetition.

This permutation and combination calculator finds ( P(n, r) ) (nPr) and ( C(n, r) ) (nCr, “n choose r”) exactly, using whole-number arithmetic so even huge answers are not rounded. It also gives the counts when repetition is allowed. Enter the total number of items n and how many you choose, r.

It’s free and needs no sign-up.

Permutation and Combination Calculator (nPr and nCr): Each number in Pascal’s triangle is C(n, r), the sum of the two above…
Each number in Pascal’s triangle is C(n, r), the sum of the two above it; row 5 gives C(5, 0) … C(5, 5) = 1, 5, 10, 10, 5, 1.

How to use it

  1. Enter n, the number of items to choose from.
  2. Enter r, the number chosen.
  3. Press Calculate.

Using a combination calculator: permutation or combination?

Ask one question: does the order matter?

  • Order matters (rankings, passwords, seating, race finishes): use a permutation.
  • Order doesn’t matter (teams, committees, lottery numbers, a hand of cards): use a combination.

Formulas

$$P(n, r) = frac{n!}{(n - r)!}, qquad C(n, r) = binom{n}{r} = frac{n!}{r!,(n - r)!}$$

where ( n! = n times (n – 1) times cdots times 2 times 1 ) and ( 0! = 1 ). Since each group of r items can be arranged in ( r! ) orders, ( P(n, r) = r! times C(n, r) ).

Worked example: 10 and 3

As loaded above.

  • Gold, silver and bronze among 10 runners (order matters): ( P(10, 3) = 10 times 9 times 8 = 720 ).
  • Choosing a 3-person committee from 10 (order doesn’t matter): ( C(10, 3) = frac{720}{3!} = frac{720}{6} = 120 ).

Worked example: poker hands

The number of 5-card hands from a 52-card deck is

$$binom{52}{5} = frac{52 times 51 times 50 times 49 times 48}{5!} = 2{,}598{,}960$$

Worked example: a lottery

Picking 6 numbers from 49, where order doesn’t matter, gives ( binom{49}{6} = 13{,}983{,}816 ) possible tickets. As a result, one ticket’s chance of the jackpot is about 1 in 14 million.

With repetition

  • Permutations with repetition: ( n^r ). For example, a 4-digit PIN using digits 0–9 has ( 10^4 = 10{,}000 ) possibilities.
  • Combinations with repetition: ( binom{n + r – 1}{r} ). For example, choosing 3 scoops from 5 ice-cream flavours, repeats allowed and order ignored, gives ( binom{7}{3} = 35 ) choices.

Summary table

Order mattersOrder doesn’t matter
No repetition( frac{n!}{(n-r)!} )( frac{n!}{r!(n-r)!} )
Repetition allowed( n^r )( binom{n+r-1}{r} )

Where combinations appear in maths

The numbers ( binom{n}{r} ) are the entries of Pascal’s triangle and the coefficients in the binomial theorem:

A hand holding a deck of playing cards, red back design.

$$(a + b)^n = sum_{r=0}^{n} binom{n}{r} a^{n-r} b^r$$

They also give the probabilities in the binomial distribution, and the same pattern appears in the binomial series, a Taylor series.

Common mistakes

  • Using permutations for a group. A committee of Ann, Ben and Cal is the same committee in any order.
  • Forgetting 0! = 1. So ( C(n, n) = C(n, 0) = 1 ).
  • r larger than n without repetition: there are no ways, so the answer is 0.

Step-by-step: which formula?

  1. Are you choosing all n items or only some (r of them)?
  2. Does the order matter? (Is ABC different from BCA?)
  3. Can items repeat? (Can you pick the same one twice?)
  4. Use the summary table above to pick the formula, and check the answer is reasonable: permutations are always at least as many as combinations.

Arrangements with repeated letters

The number of distinct arrangements of n objects where some are identical is ( frac{n!}{n_1!,n_2!cdots} ). For example, for the letters of MISSISSIPPI (11 letters: 1 M, 4 I, 4 S, 2 P):

$$frac{11!}{4!,4!,2!} = 34{,}650$$

Circular arrangements

Seating n people around a round table gives ( (n – 1)! ) arrangements, because rotating everyone one seat gives the same seating. Six people can sit in ( 5! = 120 ) ways.

Combinations and probability

The chance of exactly 2 aces in a 5-card poker hand is

$$frac{binom{4}{2}binom{48}{3}}{binom{52}{5}} = frac{6 times 17{,}296}{2{,}598{,}960} approx 0.0399$$

about 4%. Choose the aces (( binom{4}{2} )), choose the other three cards from the 48 non-aces, and divide by all possible hands. Most counting-based probability works this way.

Pascal’s triangle

Each entry is the sum of the two above it, and row n lists ( binom{n}{0}, binom{n}{1}, ldots, binom{n}{n} ):

nRow
01
11 1
21 2 1
31 3 3 1
41 4 6 4 1
51 5 10 10 5 1

Practice problems

  1. ( P(8, 2) )
  2. ( C(8, 2) )
  3. Arrangements of the letters of BOOK.
  4. Committees of 2 men and 2 women from 7 men and 5 women.

Answers: 1. ( 8 times 7 = 56 ). 2. ( frac{56}{2} = 28 ). 3. ( frac{4!}{2!} = 12 ). 4. ( binom{7}{2}binom{5}{2} = 21 times 10 = 210 ).

The fundamental counting principle

One choice has ‘m’ ways. A second choice has ‘n’ ways. Together, they have (m times n) ways. Three shirts and four trousers give (3 times 4 = 12) outfits. Permutations use this principle repeatedly. A race with 10 runners offers 10 gold choices. Then, 9 silver choices exist. Next, 8 bronze choices remain. This makes (10 times 9 times 8 = 720) ways. You can use a combination calculator for such problems.

Close-up of a calculator keypad with numbers 0-9 visible.

Worked example: passwords

An 8-character password using only lowercase letters has ( 26^8 = 208{,}827{,}064{,}576 ) possibilities (repetition allowed, order matters). Allowing the digits 0–9 as well raises it to ( 36^8 = 2{,}821{,}109{,}907{,}456 ), more than 13 times as many. This is why longer passwords with more kinds of character are much harder to guess.

Worked example: handshakes

If 10 people each shake hands once with everyone else, the number of handshakes is the number of pairs: ( binom{10}{2} = 45 ). Order doesn’t matter, since A shaking hands with B is the same handshake as B with A.

Four hands of different skin tones clasped together in a circle.

Worked example: pizza toppings

You have 8 toppings. Each topping is either on or off. This makes 2^8 = 256 possible pizzas. A combination calculator shows this. This total also equals the sum of row 8 of Pascal’s triangle. That is binom{8}{0} + binom{8}{1} + cdots + binom{8}{8}.

Factorials grow very fast

nn!
5120
103,628,800
136,227,020,800
202,432,902,008,176,640,000

A shuffled deck of 52 cards can be in ( 52! approx 8.07 times 10^{67} ) orders, so almost certainly no two well-shuffled decks in history have ever matched. Ordinary calculators overflow quickly; this calculator uses exact whole-number arithmetic instead.

Combinations with restrictions

How many 5-card hands have at least one ace? It is easier to count the opposite. Hands with no aces are ( binom{48}{5} = 1{,}712{,}304 ). So hands with at least one ace number ( 2{,}598{,}960 – 1{,}712{,}304 = 886{,}656 ). This is about 34% of all hands. Counting the complement is often the quickest route for “at least one” questions on a combination calculator.

Related guides

Further reading

FAQ

What is the difference between a permutation and a combination?

In a permutation the order matters; in a combination it doesn’t. ABC and CBA are two permutations but one combination.

What does nCr mean?

“n choose r”: the number of ways to choose r items from n when order doesn’t matter, ( frac{n!}{r!(n-r)!} ).

What is 5 choose 2?

( binom{5}{2} = frac{5 times 4}{2} = 10 ).

Why is C(n, r) equal to C(n, n − r)?

Choosing r items to take is the same as choosing the ( n – r ) items to leave behind.

What is 0! and why?

( 0! = 1 ). There is exactly one way to arrange zero objects (do nothing), and it makes formulas like ( binom{n}{0} = 1 ) work.

Why are combinations smaller than permutations?

Each combination of r items can be ordered in ( r! ) ways, so ( P(n, r) = r! times C(n, r) ).

Embed this calculator on your website

Teachers, tutors and bloggers are welcome to use this calculator for free. Copy the code below and paste it into any page (in WordPress, use a "Custom HTML" block). The small script makes the calculator grow to fit its answer; if your site removes scripts, it still works at a fixed height. Please keep the credit link.

More calculators

See all calculators