Combinations Calculator

Calculate n choose r (nCr) instantly, plus combinations with repetition. Overflow-safe multiplicative algorithm up to n = 170, with scientific notation for huge results.

Combinations

C(10, 4)

210

order-free selections

Formulan!/(r!(n−r)!) = C(10,4)
SymmetryC(10, 6) is equal
With repetition C(10+4−1, 4)715

Items and Selection Size

0–170. The cap keeps both variants inside floating-point range.

r > n gives 0 (can't choose more items than exist).

How the Calculation Works

The engine uses the multiplicative formula C(n,r) = ∏ᵢ₌₁..ᵣ (n−r+i)/i after applying the symmetry C(n,r) = C(n,n−r) to keep the loop short. Each intermediate value is itself a binomial coefficient, so the computation never touches a full factorial — that is why C(170,169) = 170 works while 169! would overflow. The with-repetition variant applies the same routine to C(n+r−1, r) (stars and bars). Results above 2⁵³ are flagged and displayed in scientific notation because 64-bit floats stop representing integers exactly there.

Common Combinations

ProblemnCrAnswerWith repetition
Poker hands (5 of 52)C(52,5)2,598,9603,819,816
Lottery 6 of 49C(49,6)13,983,81625,827,165
Committee 4 of 10C(10,4)210715
Pairs from 8 peopleC(8,2)2836

Quick Answer

A combination counts selections where order does not matter: C(n,r) = n! / (r!(n−r)!) — read "n choose r". Example: C(10,4) = 210 ways to pick 4 items from 10. Enter n (0–170) and r to get the count instantly, plus the with-repetition variant C(n+r−1, r) that allows picking the same item more than once. Results above 2⁵³ (about 9×10¹⁵) are flagged and shown in scientific notation because integer precision runs out there.

Key Facts

  • C(n,r) = n!/(r!(n−r)!) — order does not matter; C(10,4) = 210, C(52,5) = 2,598,960
  • Symmetry: C(n,r) = C(n,n−r) — choosing 4 of 10 equals leaving out 6 of 10
  • With repetition: C(n+r−1, r) — picking r items from n types when repeats are allowed (10 choose 4 with repeats = 715)
  • Edge rules: C(n,0) = 1, C(n,n) = 1, C(n,r) = 0 when r > n
  • Permutations P(n,r) = C(n,r)·r! — same selections with order counted, so P ≥ C always
  • Pascal’s rule: C(n,r) = C(n−1,r−1) + C(n−1,r), the engine of Pascal’s triangle
  • This tool uses the multiplicative formula — no raw factorials — so n = 170 computes without overflow
  • JavaScript integers are exact only up to 2⁵³ ≈ 9.007×10¹⁵; larger results are shown in scientific notation

Frequently Asked Questions

Order. A permutation counts arrangements: ABC, ACB, and BAC are three different P outcomes. A combination counts selections: those are the same set {A,B,C}, counted once. That is why P(n,r) = C(n,r) × r! — each combination of r items can be arranged r! ways. Use combinations for "how many hands/groups/committees," permutations for "how many lineups/passwords/orderings."

It never computes n! — 170! has ~307 digits and overflows floating point. Instead it uses the multiplicative formula: result = ∏(i = 1…r) (n−r+i)/i, multiplying and dividing stepwise so the running value never exceeds the final answer’s magnitude. Combined with the symmetry C(n,r) = C(n,n−r) (it picks the smaller of r and n−r), this computes every C(n,r) with n ≤ 170 — including C(170,169) = 170 — without overflow.

JavaScript numbers are 64-bit floats, which represent integers exactly only up to 2⁵³ − 1 = 9,007,199,254,740,991 (about 9 × 10¹⁵). C(54,27) ≈ 1.95 × 10¹⁵ is the last safe central binomial coefficient; C(100,50) ≈ 1.0089 × 10²⁹ cannot be held exactly. When a result exceeds 2⁵³, this tool labels it and displays scientific notation — the value is accurate to ~15–17 significant digits, not as an exact integer.

It counts selections where the same item can appear more than once — order still does not matter. Choosing 3 scoops from 5 flavors with repeats allowed is C(5+3−1, 3) = C(7,3) = 35, versus C(5,3) = 10 without repeats. The formula is C(n+r−1, r), derivable by a stars-and-bars argument: r stars separated into n groups by n−1 bars.

C(n,0) = 1: there is exactly one way to choose nothing (the empty set). C(n,n) = 1: one way to choose everything. C(n,r) = 0 when r > n: you cannot choose more items than exist. These edge cases matter in probability and in code — most naive implementations crash on them, and the multiplicative formula must special-case them explicitly.

At n = 171 the central coefficient C(171,85) ≈ 1.06 × 10⁵¹ still fits a float, but the tool caps n at 170 because beyond that the with-repetition variant C(n+r−1, r) approaches float infinity (≈1.8 × 10³⁰⁸) for large r, and integer inputs beyond 170 exceed safe display conventions. Any specific large coefficient you need can be reduced with Pascal’s rule or logs: log C(n,r) via lgamma.