Permutations & Combinations Calculator

Calculate nPr and nCr with step-by-step factorial expansion. Toggle repetition on or off with real-world examples like lottery and PIN codes.

Calculate permutations (nPr) and combinations (nCr) with and without repetition. Enter the total items and items chosen, and see the result with full factorial expansion and step-by-step working. Supports BigInt for exact results even with very large numbers.

Ad
Ad

About Permutations & Combinations Calculator

Permutations vs Combinations - Which Do I Need?

The distinction comes down to two questions: does order matter, and can items repeat?

Order Matters (Permutation)Order Does Not Matter (Combination)
No repetitionnPr = n! / (n-r)!nCr = n! / (r!(n-r)!)
With repetitionn^r(n+r-1)! / (r!(n-1)!)

Quick rule: If rearranging the same items gives a different outcome (like a PIN code), use permutations. If the selection is the same regardless of order (like a lottery draw), use combinations.

Permutations Without Repetition (nPr)

Used when you are arranging r items from n, each item used at most once, and the order of arrangement matters.

nPr = n! / (n - r)!

Worked example: How many ways can 3 runners finish first, second, and third from a race of 10?

  1. n = 10, r = 3
  2. 10P3 = 10! / (10-3)! = 10! / 7!
  3. = 10 × 9 × 8 = 720

More examples:

ScenarionrnPr
Arranging 5 books on a shelf from 8856,720
Assigning president, VP, secretary from 121231,320
4-letter codes from 26 letters (no repeats)264358,800
Seating 6 people in 6 chairs66720

Combinations Without Repetition (nCr)

Used when you are selecting r items from n, each item used at most once, and the order does not matter.

nCr = n! / (r! × (n - r)!)

Worked example: How many 5-card poker hands can be dealt from a standard 52-card deck?

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

More examples:

ScenarionrnCr
Choosing 3 toppings from 10103120
Lottery: 6 numbers from 4949613,983,816
Selecting a committee of 4 from 151541,365
Choosing 2 desserts from a menu of 88228

Permutations With Repetition

When items can be reused and order matters, the formula is simply:

n^r

Example: A 4-digit PIN using digits 0-9 (each digit can repeat):

  • n = 10, r = 4
  • 10^4 = 10,000 possible PINs
Scenarionrn^r
Binary strings of length 828256
3-letter codes (A-Z, repeats ok)26317,576
Coin flips, 10 tosses2101,024
6-character password (lowercase only)266308,915,776

Combinations With Repetition

When items can be reused and order does not matter (also called "multiset coefficients"):

(n + r - 1)! / (r! × (n - 1)!)

Example: Choosing 3 scoops from 5 ice cream flavours (same flavour can be picked again):

  • n = 5, r = 3
  • (5 + 3 - 1)! / (3! × 4!) = 7! / (6 × 24) = 5,040 / 144 = 35

Pascal's Triangle and nCr

Every entry in Pascal's triangle is a combination value. Row n, position r gives nCr:

Row (n)Values (nC0 through nCn)
01
11, 1
21, 2, 1
31, 3, 3, 1
41, 4, 6, 4, 1
51, 5, 10, 10, 5, 1
61, 6, 15, 20, 15, 6, 1

Each number is the sum of the two numbers directly above it. This gives us useful identities like nCr = (n-1)C(r-1) + (n-1)Cr.

Real-World Probability Connection

Combinations are the foundation of probability calculations. The probability of an event is often (favourable outcomes) / (total outcomes), and both counts use nCr.

Example: Probability of winning a 6/49 lottery:

  • Total outcomes: 49C6 = 13,983,816
  • Winning outcomes: 1
  • Probability: 1/13,983,816 ≈ 0.0000000715 (about 1 in 14 million)

For more probability calculations, the probability calculator handles events, conditional probability, and Bayes' theorem. For computing individual factorial values, the factorial calculator provides exact BigInt results.

Why Does Order Change Everything?

Order changes the count because every ordering of the same items becomes a distinct outcome. Picking three runners A, B, C as a podium has 3! = 6 ordered arrangements (ABC, ACB, BAC, BCA, CAB, CBA), but only one unordered set {A, B, C}. That factor of r! is exactly what separates nPr from nCr: nCr = nPr / r!. A useful sanity check when you cannot remember which formula applies: nCr will always be smaller than or equal to nPr for the same n and r, because combinations collapse all r! orderings of the same selection into a single outcome.

This r! factor also explains why combinations grow slower than permutations. For n = 20 and r = 5, nPr = 1,860,480 but nCr = 15,504 - the 120 orderings of each five-item subset get merged into one.

How Large Do These Numbers Get?

Factorials grow faster than exponentials, so permutation and combination counts explode quickly. The OEIS catalogues factorials as sequence A000142, with 20! already at 2,432,902,008,176,640,000 - past the safe range of a 64-bit integer. That is why this calculator uses JavaScript BigInt: according to the ECMA-262 specification, BigInt supports arbitrary-precision integers, so 1000! (2,568 digits) or 500C250 (149 digits) return exact results instead of overflowing or rounding.

nn!DigitsContext
103,628,8007Arrangements of 10 distinct items
136,227,020,80010Exceeds 32-bit signed integer range
202.43 x 10^1819Exceeds 64-bit signed integer range
528.07 x 10^6768Orderings of a shuffled deck of cards
1009.33 x 10^157158More than atoms in the observable universe (~10^80)
10004.02 x 10^25672568Hard cap used in this calculator

A famous implication: shuffle a 52-card deck fairly and there are 52! ≈ 8 x 10^67 possible orderings. Every well-shuffled deck in history is almost certainly unique, a result often attributed to the birthday-paradox reasoning applied to factorial state space.

Stirling's Approximation for Very Large n

Stirling's approximation estimates n! without computing every multiplication: n! ≈ sqrt(2πn) × (n/e)^n. The NIST Digital Library of Mathematical Functions gives the full asymptotic expansion. For n = 20, Stirling's estimate is 2.4228 x 10^18 against the true 2.4329 x 10^18 - accurate to within 0.42%. Relative error drops below 0.01% by n = 100. The approximation is not used for the displayed result (this tool computes exact BigInt values), but it underpins how statistics textbooks derive asymptotic forms of the binomial distribution and entropy.

Common Mistakes When Counting

  • Using permutations for a lottery. Lottery draws are order-independent - use nCr. Applying nPr inflates the count by r! and makes your odds look r! times worse than they are.
  • Forgetting to allow repetition in password or PIN counts. A 4-digit PIN has 10^4 = 10,000 outcomes, not 10P4 = 5,040, because 3333 and 5252 are valid PINs.
  • Counting identical items as distinct. Arranging the letters in MISSISSIPPI is not 11!. With repeated letters, divide by the factorials of each repeat: 11! / (4! × 4! × 2! × 1!) = 34,650.
  • Mixing up n and r. n is the total pool you draw from; r is how many you pick. Swapping them gives the wrong branch of Pascal's triangle.
  • Assuming nCr = nC(n-r) always helps. It does - and it is faster to compute nC95 as nC5 for n = 100. Use the symmetry identity when r is close to n.

Where Permutations and Combinations Appear

Combinatorics is the backbone of probability, statistics, cryptography, and computer science. A few concrete places these formulas show up:

  • Lottery odds. UK National Lottery uses 6 balls drawn from 59 (59C6 = 45,057,474). US Powerball pairs 5 white balls from 69 with 1 red from 26: 69C5 × 26 = 292,201,338 combinations for the jackpot.
  • Password strength. An 8-character password using all 95 printable ASCII characters has 95^8 ≈ 6.6 x 10^15 combinations. NIST SP 800-63B recommends length over complexity for exactly this reason - each added character multiplies the search space by the alphabet size.
  • Poker hands. 52C5 = 2,598,960 total five-card hands. Royal flushes: 4. Four-of-a-kind: 624. The probability of any named hand is (count) / 2,598,960.
  • Genetics. The number of distinct gametes produced from n heterozygous gene pairs is 2^n (permutation with repetition on {parent A, parent B} for each locus).
  • Scheduling and routing. Travelling salesman with n cities has (n-1)!/2 distinct tours. At n = 15 this is already 43,589,145,600 - which is why exact TSP requires heuristics past small instances.
  • Team selection. Picking 11 starters from a 23-man squad gives 23C11 = 1,352,078 possible starting XIs, before tactical considerations.

Binomial Coefficients and the Binomial Theorem

Combinations are also called binomial coefficients because they are the coefficients in the expansion of (x + y)^n. Wolfram MathWorld formalises this as (x + y)^n = sum from k=0 to n of nCk × x^(n-k) × y^k. Expanding (x + y)^4 gives 1x^4 + 4x^3 y + 6x^2 y^2 + 4xy^3 + 1y^4 - the coefficients 1, 4, 6, 4, 1 match row 4 of Pascal's triangle. This connection is why nCk shows up in polynomial algebra, probability (binomial distribution), and generating functions.

All calculations run in your browser. No data is sent to any server.

Sources

Frequently Asked Questions

What is the difference between permutations and combinations?

Permutations count arrangements where order matters (like rankings or PIN codes). Combinations count selections where order does not matter (like lottery numbers or committees).

What does repetition mean?

With repetition, items can be chosen more than once (like digits in a PIN - you can use 3 twice). Without repetition, each item can only be chosen once.

How large can n be?

The calculator supports n up to 1000 using BigInt for exact results. Factorials grow extremely fast, so results for large n can have hundreds of digits.

How do I know which formula to use?

Ask two questions: Does order matter? (Yes = permutation, No = combination). Can items repeat? (Yes = with repetition, No = without). This gives you one of four formulas.

What are some real-world examples?

Permutation: arranging books on a shelf, race finishing order. Combination: choosing lottery numbers, selecting a team from a group. Click the example buttons to try them.

Link to this tool

Copy this HTML to link to this tool from your website or blog.

<a href="https://toolboxkit.io/tools/permutations-combinations-calculator/" title="Permutations & Combinations Calculator - Free Online Tool">Try Permutations & Combinations Calculator on ToolboxKit.io</a>