Permutation & Combination Calculator
Count permutations P(n,r) and combinations C(n,r), with or without repetition, plus n! and r!, for lottery odds, card hands, codes and committees.
Permutation & Combination Calculator
Background.
Eight runners line up for a final with three medals on offer. How many different podiums are possible? Gold can go to any of the eight, silver to any of the seven left, bronze to any of the six after that: 8 × 7 × 6 = 336. Ask a slightly different question — how many different trios could end up on the podium, ignoring who stood where — and the answer shrinks. Each trio can be lined up in 3 × 2 × 1 = 6 orders, so there are 336 ÷ 6 = 56 of them. The first count is a permutation, the second a combination, and most counting puzzles turn on noticing which of the two is being asked.
The other question is whether an item can be used again. A runner can't take two medals, but a digit in a PIN can repeat and an ice-cream order can include two scoops of the same flavour. Allowing repeats changes the arithmetic: ordered selections become a plain power, nʳ, and unordered ones are counted by the multiset coefficient C(n + r − 1, r), the stars-and-bars formula.
Order and repetition together give four formulas. Both counts for the repetition setting you choose come back side by side, along with the factorials n! and r! that sit inside them. The numbers climb fast: a 6-from-49 lottery has 13,983,816 possible tickets, a five-card poker hand is one of 2,598,960, and a 52-card deck can be shuffled into about 8.066 × 10⁶⁷ orders.
The pool size n and the number chosen r both stop at 170. The outputs include n! and r!, and 171! is larger than the biggest value an ordinary double-precision number can hold, roughly 1.8 × 10³⁰⁸.
What is permutation & combination calculator?
A permutation is an ordered arrangement of r items taken from n distinct items; a combination is an unordered selection of r of them. Their counts are written P(n,r) or nPr, and C(n,r), nCr or the binomial coefficient "n choose r". Without repetition, P(n,r) = n!/(n − r)! and C(n,r) = n!/[r!(n − r)!], where the factorial n! is the product 1 × 2 × … × n and 0! is defined as 1. With repetition, an ordered selection fills each of r positions from all n items, giving nʳ, and an unordered selection is a multiset, counted by C(n + r − 1, r). The name binomial coefficient comes from algebra: multiply out (a + b)ⁿ and the coefficient of aⁿ⁻ʳbʳ is C(n,r), so (a + b)⁶ has coefficients 1, 6, 15, 20, 15, 6, 1, the sixth row of Pascal's triangle.
How to use this calculator.
- Enter the pool size in Total number of items (n): 49 for a 6/49 lottery, 52 for a deck of cards, 10 for the digits 0 to 9. Whole numbers from 0 to 170 are accepted.
- Enter how many you are choosing or arranging in Number of items to choose (r). Without repetition r cannot exceed n, since six cards can't be dealt from a five-card pile; with repetition it can, as in a 10-character code built from 4 symbols. Whole numbers from 0 to 170 are accepted, because r! is also shown; with repetition the calculator also refuses an n and r whose power nʳ is beyond about 1.8 × 10³⁰⁸, such as 170 symbols in 170 positions.
- Set Allow repetition? to No when each item can be used once (lottery balls, people, cards from one deck) and to Yes when it goes back into the pool (digits in a PIN, faces of a die, flavours).
- Decide whether order matters before reading the results. Use Permutations if a different order is a different outcome (rankings, codes, seating plans) and Combinations if only membership counts (hands, committees, lottery tickets).
- For a probability, divide the outcomes you care about by the total: one ticket out of 13,983,816 wins a 6/49 jackpot, a chance of about 7.151 × 10⁻⁸.
The formula.
Everything here follows from the multiplication rule: if one choice can be made in a ways and a second in b ways, the pair can be made in a × b ways.
Ordered, no repetition. The first position has n candidates, the second n − 1, and so on down to n − r + 1 for the last: P(n,r) = n × (n − 1) × … × (n − r + 1). Multiplying top and bottom by (n − r)! turns that into the compact n!/(n − r)!.
Unordered, no repetition. Every group of r items appears r! times among the ordered arrangements, once for each way of lining it up, so C(n,r) = P(n,r) ÷ r! = n!/[r!(n − r)!]. Choosing r items to keep is the same as choosing n − r to leave out, which is why C(n,r) = C(n, n − r): C(49,43) is also 13,983,816.
Ordered, with repetition. Each of the r positions has all n options, so the count is nʳ.
Unordered, with repetition. Write a selection as r stars split into n bins by n − 1 bars. Choosing 2 scoops from vanilla, chocolate and strawberry as ★★|| means two vanilla; ★|★| means one vanilla and one chocolate. Every selection is a row of n + r − 1 symbols of which r are stars, so the count is C(n + r − 1, r).
Real problems usually chain these counts with the multiplication rule and then divide. Powerball draws five white balls from 69 and one red ball from 26, and the jackpot needs all six, so there are C(69,5) × 26 = 11,238,513 × 26 = 292,201,338 possible tickets. In Texas hold'em, the chance of being dealt two aces is the number of ace pairs over the number of two-card hands, C(4,2) ÷ C(52,2) = 6 ÷ 1,326, or 1 in 221.
The convention 0! = 1 makes the edge cases come out right without special rules: there is exactly one way to choose nothing, C(n,0) = 1, and one way to take everything, C(n,n) = 1. In the cases without repetition, the ratio of permutations to combinations is always exactly r!, which is a quick way to check you have read the right line.
A worked example.
A 6/49 lottery draws six different numbers from 1 to 49, and the order they come out in makes no difference to a ticket. So n = 49, r = 6, with repetition off. Count ordered draws first: 49 × 48 × 47 × 46 × 45 × 44 = 10,068,347,520, the permutations figure. Any six numbers can be lined up in 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720 ways and a ticket doesn't care which, so divide: 10,068,347,520 ÷ 720 = 13,983,816 combinations. One ticket has a 1 in 13,983,816 chance at the jackpot, about 7.151 × 10⁻⁸. The factorial outputs read 49! ≈ 6.083 × 10⁶² and 6! = 720; written as n!/[r!(n − r)!], the 43! in the denominator cancels all but the top six factors of 49!, which is why the short product above is all the arithmetic needed. The same counts price the smaller prizes. Matching exactly three of the six drawn numbers means picking 3 of the 6 winners, C(6,3) = 20, and 3 of the 43 losers, C(43,3) = 12,341, so 20 × 12,341 = 246,820 tickets do it: about 1 in 56.66.
Frequently asked questions.
Is a combination lock really a combination?
How can I tell from the wording whether order matters?
Why is there exactly one way to choose nothing?
If I buy 100 different lottery tickets, what are my odds?
When should I turn on repetition?
How do I share out identical items, like sweets among children?
Why can't I enter n = 365 for the birthday problem?
Why do very large results look rounded?
How do I count arrangements of a word with repeated letters, like MISSISSIPPI?
How many ways can people sit around a round table?
References& sources.
- [1]Knuth, Donald E. The Art of Computer Programming, Volume 1: Fundamental Algorithms, 3rd edition. Addison-Wesley, 1997. §1.2.5 ('Permutations and Factorials') and §1.2.6 ('Binomial Coefficients') contain the canonical computer-science derivation of P(n,r), C(n,r), the multiplicative formula for binomial coefficients used by this calculator, and the integer-precision considerations for large n.
- [2]Hardy, G. H. and Wright, E. M. An Introduction to the Theory of Numbers, 6th edition, revised by Heath-Brown and Silverman. Oxford University Press, 2008. §1.2 establishes the factorial convention (0! = 1, n! = n × (n−1)!), the binomial coefficient as an integer, and the standard combinatorial identities used in this calculator.
- [3]NIST Digital Library of Mathematical Functions, Chapter 26 ('Combinatorial Analysis'), §26.3 (Multinomial Coefficients and Multinomials, Multiset Coefficients) and §26.4. Authoritative reference definitions of binomial coefficients, multiset coefficients C(n+r−1, r), multinomial coefficients, and the standard generating-function identities.
- [4]Graham, R. L., Knuth, D. E., and Patashnik, O. Concrete Mathematics: A Foundation for Computer Science, 2nd edition. Addison-Wesley, 1994. Chapter 5 ('Binomial Coefficients') is the modern definitive treatment of nCr identities, Pascal's triangle, the snake-oil method, and hypergeometric-series perspectives on combinatorial sums.
- [5]Stanley, Richard P. Enumerative Combinatorics, Volume 1, 2nd edition. Cambridge University Press, 2011. Chapter 1 ('What is Enumerative Combinatorics?') and Chapter 5 ('Trees and the Composition of Generating Functions') contain the rigorous modern treatment of stars-and-bars, multiset coefficients, and the twelvefold way — the 12-cell table classifying all elementary distribution problems.
- [6]Feller, William. An Introduction to Probability Theory and Its Applications, Volume 1, 3rd edition. Wiley, 1968. Chapter II ('Elements of Combinatorial Analysis') is the classical probabilistic application of P(n,r) and C(n,r) — birthday problem, occupancy problems, runs, and the matching problem all derive from the formulas on this page.
How this page was produced
- Published by
- Quanta Calculator
- Overseen by
- Daniel, Quanta Calculator Researcher
- Primary sources
- 6 cited below
- Method
- C(n,r) = n! ⁄ [r!(n − r)!]
- Published
- Last verified
Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 1560 calculators remain free
- No billing is enabled