Skip to main content
FastCalc

Combinations and permutations

Work out nCr and nPr — how many ways to choose r items from n, with and without order.

Combinations — order does not matter
C(52, 5)
2,598,960
Permutations — order matters
P(52, 5)
311,875,200
C(n, r) = n! / (r! x (n - r)!)
P(n, r) = n! / (n - r)!

P(52, 5) = C(52, 5) x 5!

n! = 80 658 175 170 943 878 571 660 636 856 403 766 975 289 505 440 883 277 824 000 000 000 000

Calculated in your browser. Nothing you enter is sent anywhere.

Combinations and permutations: the only difference is whether order counts

Both answer “how many ways can I pick r things from n?”, and they differ by exactly one factor: r!. If the order of your picks matters you want permutations; if it does not, you want combinations, which is the smaller number because every ordering of the same group collapses into one.

How it works

  • Computes nCr and nPr exactly, including for values far past what a normal number type can hold.
  • Shows the factorials behind the result, so the formula is checkable rather than opaque.
  • Includes presets for the two cases people actually arrive with: lottery draws and card hands.
C(n, r) = n! / (r! x (n - r)!)      
P(n, r) = n! / (n - r)!              

P(n, r) = C(n, r) x r!

ordered arrangements = unordered groups x the ways to order each group

Worked example

Five-card poker hands from a 52-card deck.

  1. n = 52, r = 5
  2. P(52,5) = 52 x 51 x 50 x 49 x 48 = 311,875,200
  3. 5! = 120
  4. C(52,5) = 311,875,200 / 120 = 2,598,960

2,598,960 distinct hands. The permutation count is 120 times larger because it counts the same five cards dealt in each of 5! = 120 orders as different outcomes — which matters for a sequence lock and does not for a poker hand.

Reading the result

  • nCr is symmetric: choosing 5 from 52 has the same count as choosing 47, because picking a group is the same act as picking everyone left out. This tool exploits that, always looping over the smaller of the two so the arithmetic stays cheap.
  • Results are computed as exact integers, not floating point. 21! already exceeds what a double can represent exactly, and 100C50 is a 30-digit number — a calculator using ordinary numbers starts returning approximations well before that and rarely says so.
  • Computing n!/(r!(n−r)!) literally overflows almost immediately. This divides at each step instead, so the running value never grows beyond the answer itself.

Common questions

Which one do I want for a lottery?
Combinations. A draw of 6 from 49 does not care what order the balls come out in, so it is C(49,6) = 13,983,816. That is the count of distinct tickets, and one in that many is your chance with a single line.
Why is nPr always bigger?
Because every unordered group is counted r! times over, once for each way of arranging it. With r = 5 that is 120 orderings of the same five items, so the permutation count is exactly 120 times the combination count.