acalculator

How many combinations?

Enter how many items there are and how many you choose to count the combinations, exactly.

Your numbers

Can an item be chosen more than once?
Combinations
2,598,960

There are 2,598,960 ways to choose 5 items from 52 when order does not matter.

Permutations (order matters)
311,875,200

Combinations: 2,598,960. There are 2,598,960 ways to choose 5 items from 52 when order does not matter.

How to calculate

Computes the number of combinations (nCr) of r items chosen from n, with or without repetition, and the matching number of permutations (nPr), exactly.

Example with the default inputs (Items to choose from (n) 52, Items chosen (r) 5, Can an item be chosen more than once? No): There are 2,598,960 ways to choose 5 items from 52 when order does not matter.

Method: Without repetition: C(n, r) = n! ÷ (r! (n − r)!) and P(n, r) = n! ÷ (n − r)!. With repetition: C(n + r − 1, r) and n^r.

  • The n items are all different from each other.
  • Without repetition, choosing more items than there are (r > n) gives 0 combinations and 0 permutations.
  • Results are exact whole numbers, however many digits they have.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. Items to choose from (n) 52, Items chosen (r) 5, Can an item be chosen more than once? No gives Combinations 2,598,960, Permutations (order matters) 311,875,200.Source: hand calculation in content.mdx: 52 × 51 × 50 × 49 × 48 ÷ 120 = 2,598,960 (DLMF 26.3.1); Python math.comb(52, 5) and math.perm(52, 5)
  2. Items to choose from (n) 49, Items chosen (r) 6, Can an item be chosen more than once? No gives Combinations 13,983,816.Source: hand calculation in content.mdx: 49 × 48 × 47 × 46 × 45 × 44 ÷ 720 = 13,983,816; Python math.comb(49, 6)
  3. Items to choose from (n) 5, Items chosen (r) 3, Can an item be chosen more than once? Yes gives Combinations 35, Permutations (order matters) 125.Source: hand calculation in content.mdx: C(5 + 3 − 1, 3) = C(7, 3) = 35; 5³ = 125
  4. Items to choose from (n) 5, Items chosen (r) 7, Can an item be chosen more than once? No gives Combinations 0, Permutations (order matters) 0.Source: DLMF 26.3.2: C(m, n) = 0 when n > m; Python math.comb(5, 7) and math.perm(5, 7) are 0
  5. Items to choose from (n) 10, Items chosen (r) 0, Can an item be chosen more than once? No gives Combinations 1, Permutations (order matters) 1.Source: DLMF 26.3.1: C(10, 0) = 10! ÷ (10! 0!) = 1; choosing nothing can be done one way

How it works

For n different items and r items chosen:

Without repetition (each item at most once):

  • Combinations (order does not matter): C(n, r) = n! ÷ (r! × (n − r)!), and C(n, r) = 0 when r > n (DLMF 26.3.1 and 26.3.2).
  • Permutations (order matters): P(n, r) = n! ÷ (n − r)! = n × (n − 1) × … × (n − r + 1), and P(n, r) = 0 when r > n. P(n, 0) = 1.

With repetition (an item may be chosen again):

  • Combinations: C(n + r − 1, r). Each choice is a list of how many times each of the n items is picked, adding up to r. Writing the r picks as stars and the n − 1 borders between items as bars, every choice is one arrangement of r stars and n − 1 bars in a row of n + r − 1 places, and there are C(n + r − 1, r) such arrangements.
  • Permutations: n^r, because each of the r places in order can hold any of the n items.

0! = 1, so C(n, 0) = 1 and P(n, 0) = 1: there is one way to choose nothing.

Assumptions

  • The n items are all different from each other. n is a whole number from 1 to 1,000, and r from 0 to 1,000.
  • Answers are exact whole numbers, however many digits they have. The calculator multiplies and divides whole numbers step by step, so nothing is rounded.

Worked examples by hand

5 cards from a 52-card deck. C(52, 5) = (52 × 51 × 50 × 49 × 48) ÷ (5 × 4 × 3 × 2 × 1) = 311,875,200 ÷ 120 = 2,598,960 poker hands. In order, the count is P(52, 5) = 52 × 51 × 50 × 49 × 48 = 311,875,200.

6 numbers from 49. C(49, 6) = (49 × 48 × 47 × 46 × 45 × 44) ÷ (6 × 5 × 4 × 3 × 2 × 1) = 10,068,347,520 ÷ 720 = 13,983,816.

3 scoops from 5 flavors, repeats allowed. C(5 + 3 − 1, 3) = C(7, 3) = (7 × 6 × 5) ÷ (3 × 2 × 1) = 210 ÷ 6 = 35. If the order of the scoops matters, there are 5³ = 125 ways.

7 items from 5 without repetition. r is larger than n, so there are 0 combinations and 0 permutations.

0 items from 10. C(10, 0) = 10! ÷ (0! × 10!) = 1, and P(10, 0) = 1.

Other questions people ask

What is the formula for combinations?

The number of ways to choose r items from n different items, when order does not matter, is C(n, r) = n! ÷ (r! × (n − r)!). For 5 cards from a 52-card deck, C(52, 5) = 52! ÷ (5! × 47!) = 2,598,960.

What is the difference between a combination and a permutation?

In a combination the order does not matter: the hand A, K, Q is the same as Q, K, A. In a permutation the order matters, so those are different. Each combination of r items can be put in order in r! ways, so permutations = combinations × r!.

What are combinations with repetition?

They count choices where the same item may be picked more than once and order does not matter, such as 3 scoops of ice cream from 5 flavors where two scoops may be the same flavor. The count is C(n + r − 1, r): here C(7, 3) = 35.

What are the odds of winning a 6 from 49 lottery?

There are C(49, 6) = 13,983,816 ways to choose 6 numbers from 49, and only one of them matches the draw, so the chance of a single ticket winning the jackpot is 1 in 13,983,816.

Why is C(n, 0) equal to 1?

There is exactly one way to choose nothing: take no items. The formula agrees, because 0! = 1, so C(n, 0) = n! ÷ (0! × n!) = 1.

What if r is bigger than n?

Without repetition you cannot choose more different items than there are, so the answer is 0 combinations and 0 permutations. With repetition, r can be larger than n, because items can be picked again.

Why does choosing r items give the same count as choosing n − r?

Every choice of r items to take is also a choice of n − r items to leave behind, so C(n, r) = C(n, n − r). For example, C(10, 3) and C(10, 7) are both 120.