Permutation & Combination Calculator
Compute permutations P(n,r) and combinations C(n,r), with and without repetition, as exact integers up to n = 1,000 — lottery odds, card hands, key spaces.
Permutation & Combination Calculator
How to use the Permutation & Combination Calculator
Determine if order matters
The key conceptual distinction: Permutation = ORDER matters (1-2-3 different from 3-2-1). Use for lock combinations, race finishes, sequencing. Combination = order does NOT matter (1-2-3 same as 3-2-1). Use for lottery draws, poker hands, committee selection. If your problem treats {A,B,C} and {C,B,A} as the same outcome → combination. If they're different outcomes → permutation.
Enter n (total pool) and r (selected count)
n = the total number of items available to choose from. r = how many you're selecting. Examples: 6/49 lottery → n=49, r=6 (choosing 6 numbers from 49). 5-card poker → n=52, r=5. 4-digit PIN → n=10, r=4, but a PIN may repeat digits, so read the "with repetition, order matters" line: 10⁴ = 10,000, not P(10,4) = 5,040. Race finishes top-3 from 8 runners → n=8, r=3 (permutation since 1st-2nd-3rd order matters).
Read both results — they relate by r!
P(n,r) = C(n,r) × r! — meaning permutations are always r-factorial times larger than combinations. For C(5,3) = 10, the corresponding P(5,3) = 60 (since 3! = 6). This is because for every UNORDERED combination of 3 items, there are 3! = 6 ORDERED arrangements. The factorial breakdown below shows n!, r!, and (n-r)! so you can verify the math by hand for small cases.
Common applications: lottery odds, poker probabilities
6-from-49 lottery jackpot odds: 1 in C(49,6) = 13,983,816. Each extra number in the pool raises that count: 6 from 50 is already 15,890,700. 5-card poker: C(52,5) = 2,598,960 hands. Royal flushes are exactly 4 of these (one per suit), so probability = 4/2,598,960 = 1 in 649,740. The calculator handles up to n=1000 with full BigInt precision — useful for genetics (DNA sequence enumeration), cryptography key spaces, and statistical sampling.
Combinatorics — when order matters and when it doesn't
Permutations and combinations are the two foundational counting tools of combinatorics — the mathematics of "how many ways" can you arrange or select items from a set. The distinction matters because it changes the answer by a factor of r! (r-factorial), which grows very fast. For a 6-from-49 selection: 720 (= 6!) times more permutations than combinations. The same physical scenario produces wildly different counts depending on whether your problem treats orderings as distinct or equivalent — which is why the first step in any combinatorics problem is always "does order matter?"
The mechanical recipe — and why it works
Permutation: P(n,r) = n × (n-1) × (n-2) × ... × (n-r+1). This is the count of sequences: first position has n choices, second has (n-1) remaining, third has (n-2), etc. Mathematically, this equals n! / (n-r)!. Combination: C(n,r) = P(n,r) / r! — divide permutations by r-factorial because every r-item combination corresponds to r! different orderings, all of which represent the same "combination". Both formulas extend naturally: permutations with repetition = n^r (a PIN may repeat a digit); combinations with repetition use the "stars and bars" count C(n+r−1, r). The calculator shows all four, and with repetition r may be larger than n.
Order matters → permutation (P). Order doesn't matter → combination (C). The ratio between them is exactly r! — for 6 items, that's 720× difference between the two counts.
Why combinatorics matters for probability
Almost every probability calculation reduces to combinatorics. P(event) = (favorable outcomes) / (total outcomes), and both numerator and denominator are usually counts of combinations or permutations. Lottery odds: P(win 6/49) = 1 / C(49,6) = 1 in 13.98 million. Royal flush in 5-card poker: 4 (one per suit) / C(52,5) = 4 / 2,598,960 = 1 in 649,740. Birthday paradox: P(any 2 of 23 people share a birthday) = 1 - (365! / (365^23 × 342!)) ≈ 50.7% — a famous result that surprises everyone. Genetics: a DNA sequence of length n can be written in 4^n ways, one of four bases at each position. The math is the same engine across all these domains.
Lottery formats, and what the format decides
The jackpot odds of a draw game are fixed by its format alone. A 6-from-49 draw has C(49,6) = 13,983,816 possible tickets, so one ticket wins the jackpot 1 time in 13,983,816 however large the prize grows. A four-digit draw game, where the numbers run from 0000 to 9999, has exactly 10,000 possible numbers, so an exact-match bet is 1 in 10,000: much shorter odds than a 6-from-49 jackpot, and in practice a much smaller prize. Bets that cover several orderings of your digits shorten the odds by exactly the number of distinct orderings those digits have — 24 for four different digits, 12 when one digit repeats. The prize for each bet type is set by the operator, so read the operator's own rules for what each pays. The count of possible draws is the fixed part; the marketing is the variable.
Whether order matters: 6/49 odds, 2,598,960 poker hands, and 52!
Permutation = ORDER matters. Combination = order does NOT matter. The ratio between them is always r! (r-factorial).
The formulas: P(n,r) = n!/(n-r)! and C(n,r) = n!/(r!(n-r)!). C is also called the "binomial coefficient" written as (n choose r).
6/49 lottery odds are 1 in 13,983,816 — C(49,6). Covering every combination means buying all 13,983,816 tickets, and a shared jackpot would still split the prize.
A standard 52-card deck has 2,598,960 distinct 5-card hands. Only 4 are royal flushes (one per suit), giving 1-in-649,740 odds.
The birthday paradox: in a room of 23 people, there's a 50.7% chance two share a birthday. By 60 people, it's 99.4%. Combinatorics in action.
52! (the number of ways to shuffle a deck) is 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000 — a 68-digit number. The calculator computes it exactly; hover the n! value to see every digit.
Pascal's Triangle visualises binomial coefficients — each entry is C(n,r) where n is the row and r is the position. The triangle's rows sum to powers of 2.
C(n, r) = C(n, n−r) always — choosing which 6 of 49 to play is the same act as choosing which 43 to leave out, so both counts are 13,983,816.
0! = 1 by definition — there is exactly ONE way to arrange zero items (the empty arrangement). Mathematically required for formulas to work.
n choose 0 = 1 always — there's exactly one way to choose nothing. n choose n = 1 — exactly one way to choose everything.
Frequently Asked Questions
-
Permutation = ORDER matters. Combination = order does NOT matter. For 3 items A, B, C choosing 2: permutations P(3,2) = 6 (AB, BA, AC, CA, BC, CB — six distinct ordered pairs); combinations C(3,2) = 3 ({A,B}, {A,C}, {B,C} — three unordered pairs). The ratio is r! (here r=2, so 2! = 2; 6/3 = 2 ✓). Use permutation for lock combinations, race finishes, signal sequences. Use combination for lottery draws, poker hands, committee selection, ingredient mixes.
-
By mathematical convention, because there is exactly one way to arrange zero items — the empty arrangement. This isn't arbitrary; it's REQUIRED for formulas to be consistent. C(n,0) should equal 1 (one way to choose nothing); the formula n!/(0!(n-0)!) only equals 1 if 0! = 1. Similarly P(n,0) = 1 only works with 0! = 1. The gamma function (continuous extension of factorial) also gives Γ(1) = 1, supporting the definition. So 0! = 1 is not a special-case hack but a mathematical necessity.
-
Jackpot odds are one divided by the number of possible draws, so the format is the whole story. 6 from 49: 1 in C(49,6) = 13,983,816. 6 from 45: 1 in 8,145,060. 6 from 59: 1 in 45,057,474. Games with a second barrel multiply the two counts. Mega Millions has players pick five numbers from 1 to 70 and one from 1 to 24, and its own prize table lists the jackpot at 1 in 290,472,336, which is C(70,5) × 24 = 12,103,014 × 24; the 1 in 302,575,350 still seen in older articles is the same count with a Mega Ball pool of 25. Powerball's prize chart lists 1 in 292,201,338, which is C(69,5) × 26 = 11,238,513 × 26. The same arithmetic covers any format: 7 from 35 plus 1 from 20 is 1 in 134,490,400, and 5 from 50 plus 2 from 12 is C(50,5) × C(12,2) = 1 in 139,838,160. Jackpot odds are not always in the millions: a 4-digit draw game has only 10,000 possible numbers (0000 to 9999), so an exact-match bet is 1 in 10,000. Buying more tickets raises your chance in proportion to what you spend without changing the odds on any single ticket.
-
Yes — up to n = 1,000 with exact integer arithmetic (no floating-point rounding), and the exactness survives all the way to the screen. Up to 30 digits every digit is printed. Past that the visible line is the exact digit count plus a scientific-notation approximation read off the exact integer itself — hover the value to see the full number. 52! = 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000 (68 digits). 171! has 310 digits and 1000! has 2,568 — all computed exactly. Above 1,000 the page declines rather than freeze your browser: n^r at n = r = 1,000 already has 3,001 digits. If you need to compute n! for n > 1000 (unusual), the result has thousands of digits — use scientific notation approximations via Stirling's formula instead.
-
The calculator shows them on the second row. For combinations WITH repetition (e.g. "how many 3-scoop cones can I make from 10 flavours, allowing repeats?") the count is C(n+r−1, r): for 3 scoops from 10 flavours, C(12, 3) = 220. For permutations WITH repetition (e.g. a 4-digit PIN with digits 0-9 allowed to repeat) it is n^r = 10^4 = 10,000. With repetition, r can be larger than n: 5 scoops from 3 flavours is C(7, 5) = 21.
-
Probability = (favorable outcomes) / (total outcomes), where both numerator and denominator are counted using combinations or permutations as appropriate. Examples: P(royal flush in 5-card poker) = (4 royal flushes possible) / (C(52,5) total hands) = 4 / 2,598,960 = 1/649,740. P(exactly 3 of 6 lottery numbers match the 6 winning) = C(6,3) × C(43,3) / C(49,6) = 20 × 12,341 / 13,983,816 ≈ 1/57. The pattern is always: count favorable (using C/P), count total (using C/P), divide.
-
Pascal's Triangle is a triangular array where row n contains the binomial coefficients C(n,0), C(n,1), ..., C(n,n). Each entry equals the sum of the two entries directly above it. Row 0: 1. Row 1: 1, 1. Row 2: 1, 2, 1. Row 3: 1, 3, 3, 1. Row 4: 1, 4, 6, 4, 1. Row 5: 1, 5, 10, 10, 5, 1. Each row sums to 2^n. The triangle visualises combinatorial identities and is the visual heart of binomial expansion — (a+b)^n's coefficients come straight from row n. It is named after Blaise Pascal, but it is far older: the Chinese mathematician Yang Hui (c. 1238–1298) gave it up to the sixth row, saying he had learnt it from Jia Xian's treatise.
-
It's the foundation of: probability theory (counting outcomes), cryptography (counting key spaces — how hard is it to brute-force a 128-bit key? 2^128 = 3.4×10^38 attempts), genetics (DNA sequence enumeration, recombination math), machine learning (sampling strategies, feature combinations), statistics (binomial + multinomial distributions), computer science (algorithm analysis, hash table sizing), game theory (strategy enumeration). The same n choose r formula that tells you lottery odds also tells you how many distinct 10-feature subsets you can extract from a 100-feature dataset for ML model selection: C(100, 10) ≈ 1.7×10^13 — too many to exhaustively try, which is why feature selection algorithms exist.
-
No. All calculations run entirely in your browser via JavaScript using BigInt for precision. There's no server roundtrip — open DevTools → Network and confirm zero outbound requests. Your inputs stay on your device. Safe for cryptographic key-space analysis, sensitive research, or any combinatorics work that shouldn't leave your machine.
-
Many real problems have multiple combinatorial steps. Example: "How many ways to choose a 4-person committee from 10 people, then designate one as chair?" Step 1: choose 4 unordered = C(10,4) = 210. Step 2: pick chair from the 4 = 4 ways. Total = 210 × 4 = 840. Equivalently: P(10,1) × C(9,3) = 10 × 84 = 840 (pick chair first, then 3 others). Multi-step problems break down into a product of permutations and combinations at each step. The calculator computes one step at a time; chain results manually for compound problems.
Method & sources
How it computes
Permutations P(n,r) = n!/(n−r)! and combinations C(n,r) = n!/(r!(n−r)!), both 0 when r > n; with repetition n^r (ordered) and C(n+r−1, r) (unordered), where r may exceed n. Every count is an exact integer (BigInt) up to n, r = 1,000; past 30 digits the page shows the digit count and 5 significant digits, with every digit on the value's tooltip (CombinatoricsKernel).
What this tool implements
- DLMF §26.3: the binomial coefficient C(m, n) is the number of ways of choosing n objects from m distinct objects without regard to order; §1.2(i) gives it as m!/((m−n)! n!). DLMF 5.4.1: Γ(1) = 1 and n! = Γ(n + 1), so 0! = 1.
- All four counts are checked against brute-force enumeration for n, r ≤ 6, against Pascal's rule for n ≤ 120, and against the operators' own jackpot odds: Mega Millions 1 in 290,472,336 = C(70,5) × 24, Powerball 1 in 292,201,338 = C(69,5) × 26.
- Worked counts the page prints and the kernel reproduces: C(49,6) = 13,983,816; C(52,5) = 2,598,960 (4 royal flushes, 1 in 649,740); 52! (68 digits); 171! (310 digits); 1000! (2,568 digits).
- History: MacTutor records that Yang Hui (c. 1238–1298) gave the triangle now named after Pascal up to the sixth row, crediting Jia Xian's treatise.
- Corrected 2026-10-19: repetition counts are now computed rather than left to the reader (the old advice could not produce n^r); unverifiable lottery-format names, an Indonesian state lottery, a "bonus ball" remark that conflated a bonus number with a second barrel, and an unsourced Pingala/Al-Karaji attribution removed; grouped input ("1,000") accepted.
Sources
- NIST Digital Library of Mathematical Functions, §26.3 Lattice Paths: Binomial Coefficients. https://dlmf.nist.gov/26.3
- NIST Digital Library of Mathematical Functions, §1.2(i) Binomial Coefficients. https://dlmf.nist.gov/1.2
- NIST Digital Library of Mathematical Functions, §5.4 Special Values and Extrema (5.4.1, Γ(1) = 1). https://dlmf.nist.gov/5.4
- Mega Millions. How to Play (5 of 1-70, 1 of 1-24; jackpot 1 in 290,472,336). https://www.megamillions.com/How-to-Play.aspx
- Powerball. Prize chart (grand prize 1 in 292,201,338). https://www.powerball.com/powerball-prize-chart
- O'Connor JJ, Robertson EF. Yang Hui. MacTutor History of Mathematics, University of St Andrews. https://mathshistory.st-andrews.ac.uk/Biographies/Yang_Hui/
What can make this go out of date
- None at runtime; nothing the reader types is sent anywhere.
Pick up where you left off
Stored only in this browser — never sent to our servers.