MathsDiscrete Math

Combination
calculator.

Count the ways to pick r things from n when the order of the picks makes no difference.

How it's worked out

A combination is a set of r items taken from n different items, where only which items you hold counts. Ann, Ben and Cara form the same team as Cara, Ann and Ben. The count is written C(n, r) and read "n choose r". The NIST Digital Library of Mathematical Functions defines it as the number of ways to choose r objects from n without regard to order.

C(n,r)\displaystyle C(n, r)=n!r!(n−r)!\displaystyle {}= \frac{n!}{r!\,(n - r)!}

The sign n!n!, said n factorial, is the product 1 × 2 × 3 and so on up to n. The reason for the formula is a simple overcount. Picking r items one at a time, in order, gives n times (n minus 1) and so on, r factors in all. Each set turns up once for every way to line it up, and r items can be lined up in r factorial ways, written r!r!. Dividing by that number removes the repeats.

In practice the larger factorial on the bottom cancels with most of the top. For 3 from 10, the factorial of 7 cancels and leaves three factors over three: 10 × 9 × 8 over 3 × 2 × 1, which is 720 over 6, or 120. The steps in the tool do the same and then check the result by multiplying back by r!r!.

C(n,r)\displaystyle C(n, r)=C(n−1,r−1)+C(n−1,r)\displaystyle {}= C(n - 1, r - 1) + C(n - 1, r)

That second line is Pascal's rule. Pick any one item: a set either holds it or does not, and those two groups add up to the whole. Choosing what to keep is also the same as choosing what to leave out, so C(10, 3) and C(10, 7) are both 120.

If the same item may be picked more than once, the count changes to C(n + r − 1, r), the stars and bars count. Three scoops from 5 flavors give 35 cups with repeats allowed, against 10 with three different flavors.

Worked examples

Priya checks the odds of her lottery ticket

Priya's lottery draws 6 balls from 49, and the order they come out in does not matter. Her ticket wins the top prize only if it holds the exact 6 numbers drawn.

C(49,6)\displaystyle C(49, 6)=49×48×47×46×45×446×5×4×3×2×1\displaystyle {}= \frac{49 \times 48 \times 47 \times 46 \times 45 \times 44}{6 \times 5 \times 4 \times 3 \times 2 \times 1}

The top multiplies out to 10,068,347,520 and the bottom to 720, so there are 13,983,816 possible tickets. With a fair draw, one ticket has a chance of 1 in 13,983,816.

If the game added a 50th ball, the count would rise to 15,890,700, about 1.14 times as many. Asking players to pick 7 numbers from 49 instead would give 85,900,584.

Open this example in the tool

Sam counts poker hands with exactly two aces

A five-card hand from a 52-card deck is a combination, since a hand is the same whatever order the cards arrive in. There are 2,598,960 hands in all.

For exactly two aces, Sam splits the hand into two choices: 2 of the 4 aces, and 3 of the 48 cards that are not aces. Those are 6 and 17,296 ways, and every pair of choices makes a different hand, so he multiplies them.

C(4,2)×C(48,3)\displaystyle C(4, 2) \times C(48, 3)=6×17,296\displaystyle {}= 6 \times 17,296=103,776\displaystyle {}= 103,776

Out of 2,598,960 hands, that is 3.99%. Use the tool for each part, C(4, 2) and C(48, 3), and multiply.

Open this example in the tool

A committee of 3, or three named roles

A club of 10 wants a committee of 3. Any three people form one committee, so there are C(10, 3) = 120 choices.

If the three take a chair, a secretary and a treasurer, the order now matters. That gives P(10, 3) = 720, which is 6 times as many, because each committee can hand out the three roles in 3!=63!=6 ways.

Open this example in the tool

Reading your result

The count, not a chance. C(n, r) counts sets. It turns into a probability only when every set is equally likely, as in a fair draw or a well shuffled deck. Then one set has a chance of 1 over the count. A team picked by a coach is not a random draw, so the count says nothing about how likely a team is.

Large numbers stay exact. Twenty numbers from 80 give 3,535,316,142,212,174,320, a 19-digit count. Ordinary floating-point arithmetic keeps only about 16 digits, so a phone calculator rounds it. This tool works in whole numbers, so every digit is correct.

Zero and one are real answers. Choosing 7 different items from 5 cannot be done, so the count is 0. Choosing nothing from 8 can be done in exactly 1 way, the empty set.

The row shows the shape. For a fixed n, the counts rise to the middle value of r and fall back in mirror image. Picking half the items gives the most sets, and picking almost all of them gives as few as picking almost none.

Common mistakes

  • Using a combination when order matters. Seats, rankings, PIN codes and race results depend on order, so they need P(n, r) or n to the power r instead.
  • Adding counts that should be multiplied. Two aces and three other cards is two choices made together, so the counts multiply. Add only when the cases cannot happen at the same time.
  • Allowing repeats by accident. A lottery ball cannot be drawn twice, but a pizza can have double cheese. Pick the rule that matches the problem before you count.
  • Dividing huge factorials on a calculator. The factorial of 52, 52!52!, has 68 digits, so the division loses digits on most calculators. Cancel the larger factorial first, as the steps do.

Questions people ask

Ask whether swapping two of the chosen items gives a new outcome. If a different order is a different result, as with a race podium, it is a permutation. If only the set matters, as with a lottery ticket, it is a combination, and the permutation count is r factorial times larger.

Sources