Combination Calculator (nCr)

A combination counts how many different unordered selections of r items you can make from n distinct items. Choosing Ann, Ben and Cara for a committee is the same combination as choosing Cara, Ben and Ann, so order is thrown away — that is the whole difference between a combination and a permutation. Enter n and r and this calculator returns C(n, r), the matching ordered count, how many orderings were collapsed into each combination, and the chance that one specific selection comes up. Switch repetition on when an item may be picked more than once.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Total items available (n)How many distinct things you are choosing from — cards in the deck, numbered balls in the drum, people on the roster.52
Items chosen (r)How many you take. Without repetition this cannot exceed n; with repetition it can.5
RepetitionChoose Yes for scoops from a tub of flavours or dice faces; choose No for cards, lottery balls or committee seats.No — each item can be chosen once

It returns

  • Number of combinations — Distinct selections when order is ignored.
  • Same choices counting order — How many ordered sequences those selections correspond to.
  • Ordered sequences per combination — Equals r! when repetition is off; with repetition it is an average, because a selection containing a repeat has fewer distinct orderings.
  • Chance of matching one specific selection — Assumes every listed selection is equally likely, which is true of a fair draw without repetition.

The formula

C(n,r)=n!r!(nr)!
C(n+r1,r)=(n+r1)!r!(n1)!
C(n,r)=C(n1,r1)+C(n1,r)

In plain text: C(n, r) = n! / (r! · (n − r)!)

  • C(n, r)Number of unordered selections of r items from n (count)
  • nTotal distinct items available (count)
  • rItems chosen (count)
  • n!Factorial of n: n × (n−1) × … × 2 × 1, with 0! = 1 (count)

C(n, r) is the binomial coefficient, also written nCr or as n above r in brackets. It is defined only for whole numbers with 0 ≤ r ≤ n; outside that range the count is zero.

Updated Category Sequences, Series & Combinatorics Verified against published test cases Reading time 12 min

What a combination counts, and what it deliberately ignores

A combination is a selection in which order carries no information. If you deal yourself the ace of spades, the seven of hearts and the two of clubs, it makes no difference which card arrived first — you hold one hand, not six. The combination count answers a single question: how many distinct sets of size r can be formed from a pool of n distinct items?

That question is everywhere once you notice it. Lottery odds are a combination count. So is the number of possible five-card poker hands, the number of ways to pick a jury of twelve from a panel of forty, the number of subsets a QA engineer must test when any three of eight feature flags may be on, and the number of terms in an expanded binomial. Every one of those problems collapses ordered outcomes that a person would describe with the same words.

The companion count is the permutation, which keeps order. Every combination of r distinct items corresponds to exactly r! orderings, so the two counts sit in a fixed ratio: P(n, r) = C(n, r) × r!. That single identity is the fastest way to decide which one you need. Ask yourself whether swapping two chosen items produces a different outcome. If it does — a podium, a PIN, a batting order — you want the permutation calculator. If it does not, you want this one.

Where n! / (r!(n − r)!) comes from

Build the formula in two moves rather than memorising it. First count the ordered selections, then divide out the orderings you did not want.

Step one: count with order. You have n choices for the first pick, n − 1 for the second, and so on down to nr + 1 for the last. Multiplying gives the falling product n(n−1)…(n−r+1), which equals n! ÷ (n − r)!. The factorials are just a compact way of writing that product: the full n! runs all the way down to 1, and dividing by (n − r)! cancels the tail you never used.

Step two: divide out the order. Each set of r distinct items was counted once for every way of arranging those r items among themselves, and there are r! such arrangements. Dividing by r! collapses them to one. That produces n! ÷ (r!(n − r)!).

Two structural facts fall straight out. C(n, r) = C(n, n − r), because choosing which items to take is the same act as choosing which to leave — that symmetry is why the reference table below is a mirror image about its centre. And Pascal's rule, C(n, r) = C(n−1, r−1) + C(n−1, r), says that every selection either contains a particular nominated item or does not; add the two cases and you have them all. Pascal's rule is what generates Pascal's triangle, and it is also the safest way to compute large coefficients by hand, since it never requires an enormous factorial. If you want the factorials themselves, the factorial calculator shows exact values and digit counts.

This calculator does not evaluate n! directly. It builds the answer by the multiplicative recurrence C(n, k) = C(n, k−1) × (n − k + 1) ÷ k, which stays exact in ordinary 64-bit arithmetic far longer, and it switches to logarithms of the gamma function once the true value passes 1015. Beyond that point the display becomes scientific notation because no exact answer will fit.

Worked example: five-card hands from a 52-card deck

How many five-card poker hands exist? Here n = 52 and r = 5, and repetition is off because a deck holds one of each card.

  1. Count the ordered deals. 52 × 51 × 50 × 49 × 48. Take it in stages: 52 × 51 = 2,652; × 50 = 132,600; × 49 = 6,497,400; × 48 = 311,875,200. That is P(52, 5).
  2. Count the orderings of one hand. 5! = 5 × 4 × 3 × 2 × 1 = 120.
  3. Divide. 311,875,200 ÷ 120 = 2,598,960 distinct hands.
  4. Convert to odds. One specific hand — say the royal flush in spades — has probability 1 ÷ 2,598,960 = 0.0000003848, or about 3.85 × 10−5 percent.

Now check the same number by the symmetry rule. C(52, 5) must equal C(52, 47), the number of ways to choose the 47 cards left in the deck. Nobody would compute the second by multiplying 47 terms, but the identity guarantees they match — and it is the reason this calculator always reduces r to the smaller of r and nr before multiplying.

One more, by hand, to fix the repetition case. A shop sells five ice-cream flavours and you buy three scoops, repeats allowed. The shifted count is n + r − 1 = 5 + 3 − 1 = 7, so the answer is C(7, 3) = (7 × 6 × 5) ÷ (3 × 2 × 1) = 210 ÷ 6 = 35 distinct tubs. The ordered count is 53 = 125, which is smaller than 35 × 6 = 210 — a direct demonstration that a selection containing a repeat has fewer than 3! distinct orderings.

How to read the result

The headline number is a count of possibilities, so its practical meaning depends entirely on what you do with it next.

As odds. If every selection is equally likely — a fair lottery draw, a well-shuffled deck, a random sample without replacement — then the probability of any one named selection is 1 ÷ C(n, r). This is where the numbers become vivid. C(49, 6) = 13,983,816, so a single UK Lotto line wins the jackpot about once in fourteen million attempts. Adding a second drum multiplies rather than adds: five white balls from 69 give C(69, 5) = 11,238,513 ways, and each pairs with one of 26 red balls, so the full space is 11,238,513 × 26 = 292,201,338. Multiplying independent stages like that is standard practice, and you can carry the result into the probability calculator or the at-least-one probability calculator if you want to know the chance across many tickets.

As a workload. Testing every three-way interaction among eight feature flags means C(8, 3) = 56 cases; among twenty flags it means C(20, 3) = 1,140. Combination counts grow polynomially in r but explosively in n, which is exactly why exhaustive testing stops being feasible so abruptly.

As a coefficient. C(n, r) is the coefficient of xr in the expansion of (1 + x)n — the same numbers that appear in the binomial expansion calculator and in the binomial probability formula. The row of coefficients peaks in the middle and falls away symmetrically; the chart this calculator draws is that shape.

Sanity-check any result three ways. C(n, 0) and C(n, n) must both be 1. C(n, 1) must be n. And the whole row for a given n must sum to 2n, since every item is either in a subset or out of it — for n = 5 the row is 1, 5, 10, 10, 5, 1, which totals 32 = 25.

Combination counts for common values of n and r

C(n, r), the number of unordered selections of r items from n distinct items, with no repetition.
nr = 2r = 3r = 4r = 5
1045120210252
201901,1404,84515,504
304354,06027,405142,506
407809,88091,390658,008
501,22519,600230,3002,118,760

Read across to see how fast the count climbs with r, and down to see how much faster it climbs with n. Going from n = 10 to n = 50 at r = 5 multiplies the count by more than eight thousand.

Mistakes that produce the wrong count

  • Using a combination where order matters. Gold, silver and bronze from eight runners is P(8, 3) = 336, not C(8, 3) = 56. The words "arrangement", "sequence", "ranking", "code" and "schedule" all signal a permutation.
  • Forgetting that the pool must hold distinct items. C(n, r) counts selections from n items you can tell apart. Choosing 3 letters from the word LEVEL is not C(5, 3), because the two Ls and two Es are interchangeable and the double counting has to be removed by hand.
  • Adding stages that should be multiplied. When a draw has separate pools — main balls plus a bonus ball, a starter plus a main plus a dessert — multiply the counts. Adding them answers a different question entirely.
  • Reaching for repetition when the pool is simply large. Repetition means the same item can appear twice in one selection. Drawing 6 balls from 49 without putting any back is a no-repetition problem even though 49 is a big pool.
  • Treating the with-repetition count as a set of equally likely outcomes. There are 21 unordered results when you roll two dice, but they are not equally likely: a 6-6 arises one way out of 36 and a 6-5 arises two ways. The count is right; the uniform-probability assumption is not.
  • Computing n! first. 52! overflows a double and 1000! has 2,568 digits, yet C(52, 5) is under three million. Cancel before you multiply, or use Pascal's rule.
  • Rounding a huge coefficient and calling it exact. Past about 1015 a 64-bit float can no longer hold every digit. This page switches to scientific notation and says so rather than printing digits it cannot vouch for.

Repetition, and the four counting problems people confuse

Counting problems sort into a two-by-two grid: order matters or it does not, repetition is allowed or it is not. Naming the cell you are in solves most of the difficulty before any arithmetic starts.

Ordered, no repetition gives P(n, r) = n! ÷ (n − r)!. Ordered, with repetition gives nr — the four-digit PIN case, 104 = 10,000. Unordered, no repetition is the standard C(n, r) on this page. Unordered, with repetition is C(n + r − 1, r), the "stars and bars" count.

That last formula deserves its picture. Lay out r stars for the items you are taking and n − 1 bars to divide them into n flavour bins. Every arrangement of the stars and bars is one selection, and there are r + n − 1 positions of which you choose r to be stars — hence C(n + r − 1, r). Three scoops from five flavours becomes three stars and four bars in seven slots: C(7, 3) = 35.

Two nearby tools handle cases this calculator does not. When your pool contains repeated identical items and you want arrangements of all of them — the letters of MISSISSIPPI, say — you need the multiset formula n! ÷ (n₁! n₂! … nk!), which the permutation calculator provides. And when you are drawing without replacement from a pool that contains two kinds of item and you want the probability of a particular mix, that is the hypergeometric distribution: five red from a bag of twelve red and eight blue is C(12, 5) × C(8, 0) ÷ C(20, 5), a ratio of combination counts that the hypergeometric distribution calculator assembles for you. If your draws are independent with a fixed success probability instead, use the binomial distribution calculator.

Key terms

Combination
An unordered selection of items from a set. Written C(n, r), nCr, or as n above r inside large brackets.
Binomial coefficient
Another name for C(n, r), used because it is the coefficient of xr when (1 + x)n is expanded.
Permutation
An ordered arrangement. P(n, r) = C(n, r) × r! for distinct items, so permutations always come out at least as large as the matching combination count.
Multiset
A collection in which the same item may appear more than once and order is still ignored. Counting multisets is the with-repetition case, C(n + r − 1, r).
Pascal's rule
C(n, r) = C(n−1, r−1) + C(n−1, r). Splits every selection according to whether it contains one nominated item, and generates Pascal's triangle row by row.
Falling factorial
The product n(n−1)…(n−r+1) — the ordered count before orderings are divided out. Equal to n! ÷ (n−r)!.

Frequently asked questions

What is the difference between a combination and a permutation?

A permutation counts orderings; a combination throws them away. For distinct items the two are linked exactly by P(n, r) = C(n, r) × r!, so a permutation count is never smaller than the matching combination count and is larger whenever r is at least 2. Ask whether swapping two of the chosen items changes the answer. Three people forming a committee: no, use a combination. Three people finishing first, second and third: yes, use a permutation.

How do I calculate nCr on a scientific calculator?

Type the value of n, press the nCr key (often labelled C or found under a PROB or MATH menu), type r, then press equals. On a TI-83/84 the path is MATH → PRB → nCr; on Casio models it is usually OPTN → PROB → nCr. Spreadsheets have it built in: =COMBIN(52,5) in Excel, Google Sheets and LibreOffice returns 2598960, and =COMBINA(5,3) gives the with-repetition count of 35.

Why is 0! equal to 1?

Because there is exactly one way to arrange nothing — the empty arrangement — and because the definition keeps every formula that uses factorials consistent. Set r = n in C(n, r) = n!/(r!(n−r)!) and you get n!/(n!·0!), which must equal 1 since there is only one way to take everything. That forces 0! = 1. The same convention makes C(n, 0) = 1: choosing nothing is one valid selection.

What does nCr mean when repetition is allowed?

It becomes C(n + r − 1, r), the number of distinct multisets of size r drawn from n kinds of item. The shift accounts for the extra freedom: with five flavours and three scoops there are C(7, 3) = 35 possible tubs, against C(5, 3) = 10 if every scoop had to be a different flavour. Set the repetition selector to Yes and the calculator applies the shifted formula and shows the shifted count as a step.

How many combinations are there in a 6/49 lottery?

C(49, 6) = 13,983,816. Work it as (49 × 48 × 47 × 46 × 45 × 44) ÷ 720: the numerator is 10,068,347,520 and dividing by 6! = 720 gives 13,983,816. A single line therefore matches all six numbers with probability 1 in 13,983,816, or about 0.00000715%. Buying ten distinct lines multiplies the chance by ten; it does not meaningfully change the order of magnitude.

Can r be larger than n?

Only when repetition is allowed. Without repetition the count is exactly zero, because you have run out of distinct items to take — the calculator returns 0 and flags it. With repetition there is no upper limit on r: choosing 10 scoops from 3 flavours is C(12, 10) = 66, a perfectly ordinary answer.

Why does the answer switch to scientific notation?

Because the exact value no longer fits. JavaScript numbers hold integers exactly only up to 9,007,199,254,740,991, so beyond about 1015 this page computes the result through logarithms of the gamma function and reports six significant figures instead of a long string of digits it cannot guarantee. C(100, 50), for example, is roughly 1.00891 × 1029. If you need every digit of a coefficient that large, use an exact-arithmetic system such as Python's math.comb.

What counts as a normal size for a combination problem?

Hand-workable problems almost always keep r at 5 or below, because the multiplication stays short. Real applications sit in wildly different ranges: pairwise test coverage over 20 parameters is C(20, 2) = 190 cases, a bridge hand is C(52, 13) = 635,013,559,600, and a 5-of-70 draw runs to C(70, 5) = 12,103,014. If your count exceeds a few million, the useful reading is almost always the reciprocal — the odds — rather than the count itself.

References