Combinations, Permutations & Factorial Calculator
How many ways to choose, rank or order things? Counting answers with three tools: the factorial, permutations (order matters) and combinations (order is irrelevant). Enter the total n and the number chosen k, with or without repetition.
The key question: does order matter? A podium (gold, silver, bronze) is a permutation — order tells outcomes apart. A poker hand or lottery numbers are a combination — only the set counts, not the order it was drawn.
Inputs
Result
- C(49, 6) 13,983,816
| n (items available) | 49 |
| k (items chosen) | 6 |
| Combinations without repetition C(n, k) | 13,983,816 |
| Combinations with repetition C(n+k−1, k) | 25,827,165 |
C(n, k) = n! / [ k! · (n − k)! ]
Order or no order: that is the whole fork
Counting rests on one building block, the factorial. n! is the number of ways to line up n distinct items: n choices for first place, n − 1 for second, down to 1. 0! is defined as 1, so the empty lineup is not a special case that blows up a formula. 5! = 120 is a small poker-table number. 20! is already 2.43 × 10¹⁸. Growth is the point, and the trap.
Permutations and combinations are that same product, stopped after k steps, and then either left as an ordered count or divided by the k! ways to shuffle the chosen items. Calculators label them nPr and nCr. Same objects as P(n, k) and C(n, k). The key question is always: does order distinguish two outcomes, or are they the same pile?
P(n, k) = n! / (n − k)! · C(n, k) = P(n, k) / k! = n! / [k! · (n − k)!]
Look at a podium versus a committee. Gold-silver-bronze from the same three people is six different podiums and one committee. That factor of 3! = 6 is exactly the division that turns a permutation into a combination. Get the fork wrong and every lottery, every password, every “how many hands” problem is off by k! — not a rounding error, a different sport.
Permutations: order matters (nPr)
A permutation P(n, k) counts the ways to pick k items from n and keep the order. First, second, third are different seats. The product is n × (n − 1) × … × (n − k + 1), k factors, no factorial of n required if you would rather not compute 49! just to cancel most of it.
A podium of 3 from 8 athletes: P(8, 3) = 8 × 7 × 6 = 336 possible podiums. Alice-Bob-Cara is not Cara-Bob-Alice. Rankings, race results, the first k finishers, a president-then-treasurer-then-secretary slate: permutations. Passwords can be permutations if characters must be distinct; most real passwords allow repeats, which is nk instead — a later section.
P(n, k) = n × (n − 1) × … × (n − k + 1) = n! / (n − k)!
P(n, n) = n!, the full shuffle. P(n, 0) = 1, P(n, 1) = n. If k > n and there is no replacement, the count is zero: you cannot seat 6 distinct people in 5 chairs. This page refuses that input rather than print a negative factorial.
The thing is, “password” is the example that most often gets dumped in the permutation bin by habit. A 4-digit PIN with repeats allowed is not P(10, 4) = 5,040. It is 10⁴ = 10,000. Ordered, yes. Without replacement, no.
Combinations: order is irrelevant (nCr)
A combination C(n, k) — also the binomial coefficient, also nCr — counts the ways to pick k items from n as a set. The hand {A♥, K♥, Q♥, J♥, 10♥} is one hand, however the dealer slid the cards. You take the permutation and divide by k!, the number of orderings of those k cards.
A 5-card hand from 52: C(52, 5) = 2,598,960 hands. That is the size of the sample space for every poker-probability question that starts “a random 5-card hand…”. A committee of 4 from 20 is C(20, 4) = 4,845. The lottery ticket with six numbers is a combination. If you used P(52, 5) for poker you would be counting the same hand 120 times.
C(n, k) = n! / [k! · (n − k)!] with C(n, k) = C(n, n − k)
The last identity is the “leave the rest” trick: choosing 6 from 49 is the same count as leaving 43 behind. The page uses it internally so the product stays small. C(n, 0) = C(n, n) = 1. C(n, 1) = n. None of those needs a 170-term factorial.
On that score, a “combination lock” is a marketing name. The sequence 1-2-3-4 is not 4-3-2-1. That device is a permutation with repetition: nk. Language and the formula do not agree. Trust the formula.
With or without replacement
Two more forks, sitting on top of order-or-not. Can an item come back? Drawing a card and putting it back is replacement. Dealing a hand is not. Typing a PIN is replacement (the digit 7 can appear twice). Dealing a podium of distinct athletes is not.
- Without replacement, order matters — P(n, k) = nPr. Podiums, distinct-character codes, seating k people from n.
- Without replacement, order does not — C(n, k) = nCr. Hands, committees, lottery tickets, unordered samples.
- With replacement, order matters — nk. PINs, passwords, licence plates, a k-letter word over an alphabet of n, rolling a die k times.
- With replacement, order does not — C(n + k − 1, k), “stars and bars”. Multisets: scoops of ice cream where vanilla-vanilla-chocolate is one order, not two; non-negative integer solutions of x₁ + … + xn = k.
This page prints both members of the pair you picked: C(n, k) and C(n + k − 1, k) in combination mode, P(n, k) and nk in permutation mode. Read the one that matches the physical process. Mixing them is how 10,000 PIN codes become 5,040 on a homework key, and then a security review.
Concretely: 4 digits, 10 symbols, repeats allowed → 10,000. Repeats forbidden → P(10, 4) = 5,040. Same digits, a “pick 4 numbers, order ignored, no repeats” lottery → C(10, 4) = 210. Four questions, four formulas. The story in the sentence decides, not the size of n and k.
A 6-from-49 lottery
In a “6 numbers from 49” draw, the order the balls pop out does not make a different ticket. 3-12-17-28-40-44 is the same ticket as 44-40-28-17-12-3. The sample space is C(49, 6) = 13,983,816. One ticket, one matching combination, odds of 1 in nearly 14 million. Type n = 49 and k = 6; the page is already filled with that example.
C(49, 6) = 49! / (6! · 43!) = 13,983,816
Using P(49, 6) = 10,068,347,520 would count each ticket 720 times (6!). The jackpot would look 720 times harder than it is, which is a strange way to be pessimistic. Matching exactly 3 of 6 is another combination ratio: choose 3 from the 6 drawn and 3 from the 43 not drawn, then divide by C(49, 6). Lower prize tiers are all that same pattern.
UK Lotto, older German 6aus49, many state games: same skeleton, sometimes a bonus ball on the side. The bonus is a second, smaller combination (often C(m, 1) = m) multiplied in. Powerball, next, is that idea with American numbers. The probability of a ticket is 1 over the combination count — a ratio of integers, not an area under a bell curve.
Powerball: two drums, one product
US Powerball is not “pick 6”. It is 5 white balls from 69, plus 1 red Powerball from 26 on a separate drum. White order does not matter. The red is independent. Jackpot tickets:
C(69, 5) × 26 = 11,238,513 × 26 = 292,201,338
One ticket in 292 million for the jackpot. Matching 5 white and missing the red is C(69, 5) × 25, a million-dollar tier, still grim. The two drums multiply because the draws are independent; you do not add 26 to 69 and take C(95, 6). That is a different game that nobody is running.
Mega Millions is the sibling: 5 from 70 times 1 from 25, currently 302,575,350 jackpot combinations. The arithmetic does not care which logo is on the ticket. Anyway, buying 100 tickets moves you from 1 in 292 million to 100 in 292 million. The expected value is a separate (and usually negative) conversation. This page only counts the sample space.
Try n = 69, k = 5 in combination mode for the white drum, then multiply by 26 yourself. The calculator does not have a “bonus ball” field; the product of two combinations is yours to finish.
PINs, passwords and the nk world
A 4-digit PIN, digits 0–9, repeats allowed, order matters: 10⁴ = 10,000. A 6-digit PIN is a million. Those are not combinations. They are functions from k positions to n symbols — arrangements with repetition, nk, the second line this page prints in permutation mode.
- 4-digit PIN — 10⁴ = 10,000. P(10, 4) = 5,040 only if repeats are banned, which they are not.
- 8 lowercase letters — 26⁸ = 208,827,064,576.
- 8 characters, letters + digits — 62⁸ ≈ 2.18 × 10¹⁴.
- 8 characters, mixed case + digits + a 32-symbol set — 94⁸, in the 6 × 10¹⁵ region.
Never mind the marketing copy that says “combination”. Length beats a fancy alphabet for a while, then the alphabet catches up: 6 characters of 94 symbols already outrun 12 digits. Online throttling and hashing matter more than the raw count once you leave textbook PINs, but the raw count is still the size of the haystack.
If a site demands “no repeated characters”, switch to P(n, k). If it allows repeats, stay on nk. If someone quotes C(26, 8) for an 8-letter password they have thrown away both order and repetition, and undercounted by a factor of about 40,000. That is not a conservative security estimate. It is a wrong model.
Poker hands: ranking 2,598,960 combinations
Five cards from 52, order ignored, no replacement: C(52, 5) = 2,598,960. Every standard 5-card poker probability is a numerator of favourable hands over that denominator. The ranking is a partition of the same 2.6 million.
- Royal flush — 4 (one per suit).
- Straight flush — 36 (royals counted separately; 40 if you fold them in).
- Four of a kind — 624.
- Full house — 3,744.
- Flush — 5,108.
- Straight — 10,200.
- Three of a kind — 54,912.
- Two pair — 123,552.
- One pair — 1,098,240.
- High card — 1,302,540.
Those ten numbers add to 2,598,960. A pair is not rare; more than 40 % of hands have one. A flush is rarer than a straight, which is why it ranks higher — the combination count is the ranking. Texas Hold'em is a different sample space (two hole cards plus a board); do not paste C(52, 5) into a Hold'em odds article and call it done. For a sample of hands you actually dealt, the descriptive statistics page will summarise frequencies; it will not replace C(52, 5).
To rebuild a row: four of a kind is C(13, 1) ways to pick the rank, C(4, 4) = 1 way to take all four, then 12 × 4 kickers = 624. Full house: C(13, 1) for the trips, C(4, 3) for the suits, C(12, 1) for the pair rank, C(4, 2) for its suits. Same toolkit as the lottery tier: products of C(n, k).
Why 170! is the wall
IEEE-754 double precision tops out near 1.8 × 10³⁰⁸. 170! is about 7.26 × 10³⁰⁶. 171! overflows to infinity. That is why this page refuses a factorial above 170 and why large P(n, k) and C(n, k) eventually print in scientific notation, then as “too large to compute”. The mathematics did not stop. The 64-bit float did.
Factorials grow staggeringly fast: 170! already brushes the floating-point limit (≈ 1.8 × 10³⁰⁸). Beyond that, the calculator shows large results in scientific notation and flags any overflow. For exact integers past that wall you need big-integer arithmetic, not a double.
The combination routine does not compute n! / (k! (n − k)!) as three giant factorials. It multiplies k terms of the form (n − k + i)/i, which stays in range much longer and stays exact for longer too. P(n, k) is a falling product of k terms. Asking for 200! is a different request from asking for C(200, 3), which is only 1,313,400 and fits in an integer you could write by hand.
Stirling's approximation n! ≈ √(2πn) (n/e)n is how you estimate a factorial that will not fit. This page does not use it; it either multiplies or it tells you the float died. If you need C(1000, 40) exactly, you want a computer-algebra system. If you need it to a few significant figures for an odds conversation, the double is already more honest than the newspaper headline.