DigitHelm

Combination Calculator | nCr & n Choose r

Calculate C(n,r) combinations without repetition, C̄(n,r) with repetition, P(n,r) permutations, and nʳ, all in one tool. Supports BigInt exact arithmetic for large n, step-by-step working, Pascal's triangle, combination listing, and session persistence.

Mode

Presets

Press Enter to calculate  ·  Esc to reset

What Is the Combination Calculator | nCr & n Choose r?

The combination formula answers a deceptively simple question: in how many ways can you select r items from a group of n, if the order of selection does not matter? Whether you are choosing lottery numbers, forming a committee, dealing a card hand, or selecting toppings on a pizza, combinations are the mathematical tool that counts the possibilities.

  • All four formulas in one view, C(n,r) without repetition, C̄(n,r) with repetition, P(n,r) permutations, and nʳ permutations with repetition.
  • BigInt exact arithmetic, results for large n and r (lottery-scale problems) are computed exactly with JavaScript BigInt, not floating-point approximations.
  • Step-by-step working, toggle to see how the numerator simplifies by cancelling the (n−r)! factor, revealing the multiplicative form.
  • Combinations list, for small inputs, every subset is generated and listed so you can see exactly which combinations exist.
  • Pascal's triangle, for n ≤ 16, the highlighted triangle shows where your result lives among all binomial coefficients.
  • log₁₀ scale indicator, for astronomically large results, the logarithm tells you the order of magnitude at a glance.

Formula

Combinations Without Repetition (standard nCr)

C(n, r) = n! / (r! × (n − r)!)

= [n × (n−1) × … × (n−r+1)] / r!

Combinations With Repetition (multiset coefficient)

C̄(n, r) = C(n + r − 1, r) = (n+r−1)! / (r! × (n−1)!)

Permutations Without Repetition

P(n, r) = n! / (n − r)! = n × (n−1) × … × (n−r+1)

Permutations With Repetition

P̄(n, r) = nʳ

Relationship

P(n, r) = C(n, r) × r! → C(n, r) = P(n, r) / r!

SymbolNameDescription
nTotal itemsThe size of the set you are selecting from, must be ≥ r
rItems chosenThe number of items selected from the set
n!n factorialn × (n−1) × (n−2) × … × 2 × 1, e.g. 5! = 120
C(n,r)Binomial coefficient"n choose r", the count of size-r subsets of an n-set
C̄(n,r)Multiset coefficientCombinations when items may be selected more than once
P(n,r)PermutationOrdered arrangements of r distinct items from n
P̄(n,r)Perm. with repetitionSequences of length r from n items, repeats allowed
r!r factorialThe factor that converts permutations to combinations

Key Identities

C(n, 0) = C(n, n) = 1 (empty set and full set, one way each)

C(n, 1) = n (single-element subsets)

C(n, r) = C(n, n−r) (symmetry / complement rule)

C(n, r) + C(n, r−1) = C(n+1, r) (Pascal's identity)

Σᵣ C(n, r) = 2ⁿ (sum of row n in Pascal's triangle)

How to Use

  1. 1
    Choose mode: Select "Without Repetition" for standard combinations C(n,r), items can only be chosen once. Select "With Repetition" for multiset combinations where items can repeat (e.g. ice cream scoops from a menu).
  2. 2
    Enter n and r: Type your total count (n) and selection size (r). Use the presets for common real-world scenarios: lottery 6/49, poker hand, committee selection.
  3. 3
    Press Calculate or Enter: All four combinatorial values appear instantly, without repetition, with repetition, and both permutation variants.
  4. 4
    Expand step-by-step: Click "Show Step-by-Step" to see how the formula simplifies: the (n−r)! term cancels to give the compact multiplicative form.
  5. 5
    List or visualize: For small inputs (C(n,r) ≤ 300), click "List All Combinations" to enumerate every subset. Pascal's triangle appears automatically for n ≤ 16.

Example Calculation

Example 1, Lottery 6/49

A standard lottery asks you to pick 6 numbers from 1 to 49. How many unique tickets exist?

n = 49, r = 6

C(49, 6) = 49! / (6! × 43!)

= (49 × 48 × 47 × 46 × 45 × 44) / (6 × 5 × 4 × 3 × 2 × 1)

= 10,068,347,520 / 720

= 13,983,816

Your odds of winning are 1 in 13,983,816, about one in fourteen million. The order in which you pick your numbers doesn't affect whether you win, which is why combinations (not permutations) are the correct count.

Example 2, 5-Card Poker Hand

A standard deck has 52 cards. How many distinct 5-card hands are possible?

n = 52, r = 5

C(52, 5) = (52 × 51 × 50 × 49 × 48) / (5 × 4 × 3 × 2 × 1)

= 311,875,200 / 120

= 2,598,960

The probability of being dealt a specific hand like a Royal Flush (there are exactly 4) is 4 / 2,598,960 ≈ 1 in 649,740.

Example 3, Ice Cream With Repetition

An ice cream shop has 5 flavors. You want 3 scoops and can choose the same flavor more than once. How many unique combinations of 3 scoops are there?

n = 5 (flavors), r = 3 (scoops), repetition allowed

C̄(5, 3) = C(5 + 3 − 1, 3) = C(7, 3)

= 7! / (3! × 4!) = (7 × 6 × 5) / (3 × 2 × 1)

= 210 / 6 = 35

Without repetition it would be C(5,3) = 10. Allowing repeats increases the count from 10 to 35, the multiset coefficient captures those extra possibilities.

Example 4, Committee vs. Ordered Panel

10 candidates, choosing 3. Does order matter?

Unordered committee: C(10, 3) = 10! / (3! × 7!) = 120

Ordered panel (President, VP, Secretary): P(10, 3) = 10 × 9 × 8 = 720

Ratio: 720 / 120 = 6 = 3! ✓ (confirming P = C × r!)

Understanding Combination | nCr & n Choose r

Combinations appear everywhere you need to count selections where the order does not matter. The binomial coefficient C(n, r), read “n choose r”, is one of the most frequently used quantities in mathematics, statistics, and computer science. It forms the foundation of the binomial theorem, probability theory, and even compression algorithms.

Combinations vs. Permutations, When Does Order Matter?

ScenarioOrder matters?FormulaExample (n=4, r=2)
Selecting a committeeNoC(n,r) = n!/(r!(n−r)!)C(4,2) = 6
Assigning ranked awardsYesP(n,r) = n!/(n−r)!P(4,2) = 12
Choosing a PIN (repeats OK)Yes + repeat4² = 16
Choosing toppings (repeats OK)No + repeatC(n+r−1, r)C(5,2) = 10

Pascal's Triangle and the Binomial Theorem

Every entry in Pascal's Triangle is a binomial coefficient C(n, r). Row n contains the coefficients of (a + b)ⁿ in the expansion (a + b)ⁿ = Σ C(n,k) aⁿ⁻ᵏ bᵏ. This connects combination counting directly to algebra. Key properties of the triangle:

  • Each interior entry is the sum of the two entries directly above it, Pascal's identity: C(n,r) = C(n−1,r−1) + C(n−1,r)
  • Each row sums to a power of 2: row n sums to 2ⁿ, because every subset of an n-set is counted once
  • The diagonal of 1s, natural numbers, triangular numbers, and tetrahedral numbers are all hiding in plain sight
  • Binomial distribution probabilities are computed using C(n,k), the triangle gives all the weights at once

Real-World Applications

FieldApplicationFormula used
Probability & statisticsCounting equally-likely outcomes for event probabilityC(n,r) / C(total, r)
Gambling & lotteriesCalculating odds of winning number combinationsC(49,6) = 13,983,816
Card gamesHand probability, Royal Flush, full house, straightC(52,5) = 2,598,960
Computer scienceSubset enumeration, graph theory, algorithm analysisC(n,r) subsets
Biology & geneticsGenotype combinations from allele poolsC(n,r) genotypes
ChemistryIsomer counting, molecular bond configurationsC(atoms, bonds)
Survey designChoosing questions or samples without replacementC(n,r) samples
Network designNumber of direct connections in n-node networkC(n,2) = n(n−1)/2

Special Values & Useful Reference

ExpressionValueInterpretation
C(n, 0)1Only one way to choose nothing
C(n, 1)nn ways to choose a single item
C(n, 2)n(n−1)/2Number of pairs from n items
C(n, n)1Only one way to choose everything
C(n, n−1)nComplement of choosing 1
C(n, r)= C(n, n−r)Symmetry: complement rule
C(2n, n)centralLargest value in row 2n
Σ C(n,r)2ⁿSum over all r, total subsets of n-set

The Multiplicative Formula, Why It's Faster

The standard factorial formula C(n,r) = n! / (r!(n−r)!) requires computing three enormous factorials. The multiplicative shortcut avoids this: since (n−r)! cancels from numerator and denominator, you only need the top r terms of n!:

C(n, r) = [n × (n−1) × … × (n−r+1)] / [r × (r−1) × … × 1]

C(10, 3) = (10 × 9 × 8) / (3 × 2 × 1) = 720 / 6 = 120

Only r multiplications needed instead of computing all three factorials

For large n and small r (like lottery problems where n = 49, r = 6), this is dramatically more efficient than computing 49!, a 63-digit number, before dividing.

Frequently Asked Questions

What is the difference between a combination and a permutation?

The key distinction is whether order matters.

  • Combination, order does NOT matter. {A, B, C} and {C, A, B} are the same selection.
  • Permutation, order DOES matter. (A, B, C) and (C, A, B) are different arrangements.

A simple test: if you can swap two items in your selection and get the same result, use a combination. If swapping creates something different, use a permutation.

Mathematically: P(n,r) = C(n,r) × r!, permutations equal combinations multiplied by the number of orderings of the chosen items.

How do I know whether to use C(n,r) with or without repetition?

Ask: can I pick the same item more than once?

  • Without repetition (standard), drawing lottery numbers, choosing team members, dealing cards. Once an item is chosen, it cannot be chosen again.
  • With repetition (multiset), choosing ice cream scoops where you can pick the same flavor twice, selecting letters for a word allowing duplicates, or distributing identical objects.

Formula reminder: C̄(n, r) = C(n + r − 1, r). The trick is replacing n with n + r − 1 to account for the extra "slots" created by repetition.

Why is C(n, r) = C(n, n − r)?

This is the symmetry identity (complement rule). Choosing r items to include is the same as choosing n − r items to exclude.

For example: C(10, 3) = C(10, 7) = 120. Picking 3 items to keep is equivalent to picking 7 items to leave out. The total number of distinct selections is identical.

Practically: always use the smaller of r and n − r in your computation to minimize the number of multiplications needed.

What is Pascal's identity and why does it matter?

Pascal's identity states: C(n, r) = C(n−1, r−1) + C(n−1, r)

In plain English: the number of r-subsets of n items equals the r-subsets that include item n plus the r-subsets that exclude item n.

  • This is why every Pascal's Triangle entry is the sum of the two entries above it.
  • It gives a recursive way to compute C(n,r) without any division, useful in integer arithmetic.
  • It underpins dynamic programming solutions in combinatorics problems.

How do I calculate C(n, r) by hand for large numbers?

Use the multiplicative formula to avoid computing full factorials:

C(n, r) = [n × (n−1) × … × (n−r+1)] / r!

Example: C(20, 4) = (20 × 19 × 18 × 17) / (4 × 3 × 2 × 1)

= 116,280 / 24 = 4,845

Tips for hand calculation:

  • Always use the smaller of r and n−r (symmetry identity reduces multiplications).
  • Cancel factors between numerator and denominator before multiplying through, avoids intermediate overflow.
  • For very large n, use Stirling's approximation: log(n!) ≈ n·log(n) − n + 0.5·log(2πn).

What is the connection between combinations and the binomial theorem?

The binomial theorem states: (a + b)ⁿ = Σ C(n, k) × aⁿ⁻ᵏ × bᵏ

The coefficient of each term in the expansion is a binomial coefficient, hence the name. For example:

(a + b)⁴ = C(4,0)a⁴ + C(4,1)a³b + C(4,2)a²b² + C(4,3)ab³ + C(4,4)b⁴

= a⁴ + 4a³b + 6a²b² + 4ab³ + b⁴

This connects directly to the binomial distribution, where C(n,k) is the weight of the probability P(X=k).

How do combinations apply to probability calculations?

When all outcomes are equally likely, the probability of an event is:

P(event) = (favorable combinations) / (total combinations)

P(Royal Flush) = 4 / C(52, 5) = 4 / 2,598,960 ≈ 0.000154%

  • Hypergeometric distribution, probability of k successes in n draws without replacement uses C(K,k)·C(N−K,n−k)/C(N,n).
  • Lottery odds, exactly C(n,r) equally-likely outcomes, so P(jackpot) = 1/C(n,r).
  • Genetics, number of possible offspring genotypes from allele combinations uses C(n,r).

Why does this calculator use exact BigInt arithmetic?

JavaScript's standard 64-bit floating-point numbers lose precision around 2⁵³ ≈ 9 × 10¹⁵. For reference, C(49, 6) = 13,983,816 fits fine, but C(100, 50) ≈ 10²⁹ does not.

Using JavaScript's BigInt type gives:

  • Exact integer results with no floating-point rounding errors, for any input.
  • Correct results for lottery-scale and cryptographic applications.
  • The multiplicative formula keeps intermediate BigInt values manageable without computing full factorials.

For truly enormous results (hundreds of digits), the calculator also shows log₁₀(C(n,r)) so you can understand the scale without reading hundreds of digits.

Related Calculators