Permutation & Combination Calculator
Free permutation and combination calculator: compute P(n,r), C(n,r), and n! with or without repetition, with worked examples and primary-source citations.
Permutation & Combination Calculator
Background.
The Quanta permutation and combination calculator computes the four headline quantities of elementary combinatorics — P(n,r), C(n,r), n!, and r! — for any non-negative integers n and r with 0 ≤ n ≤ 170, with or without repetition, in a single step. Enter n = 49 and r = 6 with repetition disabled and the calculator returns C(49,6) = 13,983,816 — the celebrated odds of any single 6/49 lottery ticket. Enter n = 10 and r = 3 with repetition enabled and you get 10³ = 1,000 ordered three-digit codes (000 through 999) and C(12,3) = 220 unordered three-scoop ice-cream selections from ten flavours where each flavour can repeat.
The distinction the calculator is built around is the single most important one in combinatorics: a permutation counts ordered arrangements, a combination counts unordered selections. If the order in which you pick matters — the gold-silver-bronze finish of a race, the first three digits of a PIN, the seating arrangement around a table — you want a permutation. If the order is irrelevant — the six numbers on a lottery ticket, the five-card poker hand, the three students who will represent the class on a committee — you want a combination. The mathematical bridge between them is the factor r!: every unordered combination of r items corresponds to exactly r! distinct ordered permutations, so C(n,r) = P(n,r) / r!. That single relationship, together with the formula P(n,r) = n!/(n−r)!, generates almost every counting argument in introductory probability.
The 'with repetition' flag covers the second axis of choice. When items can be re-used — rolling dice, choosing characters for a password where letters can repeat, selecting ice-cream scoops, or assigning indistinguishable balls to distinguishable boxes — the formulas change. Ordered selection with repetition is the simplest: r independent positions, each with n choices, giving P(n,r) = nʳ. Unordered selection with repetition is the famous 'stars and bars' problem, with the multiset coefficient C(n+r−1, r) — the number of weak compositions of r into n parts. NIST DLMF §26.3 collects the full table of four formulas, one for each combination of ordered/unordered and with/without repetition, and the calculator implements every cell.
Under the hood the engine uses arbitrary-precision BigInt arithmetic so that factorials and binomials are computed exactly: there is no rounding error, no overflow in intermediate steps, and no spurious floating-point drift on values like C(50,25) = 126,410,606,437,752. Results are converted to JavaScript numbers only at the output boundary, which means n! is exact for n ≤ 18 (18! = 6,402,373,705,728,000 just fits in Number.MAX_SAFE_INTEGER = 2⁵³−1) and is a finite approximation thereafter, with the renderer applying scientific notation through the CalculatorConfig format spec.
Permutations and combinations are everywhere once you start looking: the 2,598,960 distinct five-card poker hands (C(52,5)); the 1,326 starting two-card hands in Texas Hold'em (C(52,2)); the 175,711,536 Powerball jackpot tickets (C(69,5) × 26 for the Powerball pick); the 720 ways to arrange six people around a circular table (5! for circular permutations); the 1.0 × 10⁶⁸ orderings of a 52-card deck (52! — more than the number of atoms in the observable galaxy). Every committee selection, every tournament bracket, every birthday-paradox calculation, every Boolean function counting argument, every Bayesian update with a multinomial prior — all of them reduce, at some level, to choosing whether order matters and whether repetition is allowed, and then writing down the appropriate formula from the table on this page. This calculator does the arithmetic and explains the choice so you do not have to remember the formula sheet.
What is permutation & combination calculator?
A permutation is an ordered arrangement of r items chosen from a set of n. The number of permutations is denoted P(n,r), nPr, or (n)_r (the 'falling factorial'). Without repetition, P(n,r) = n × (n−1) × (n−2) × … × (n−r+1) = n!/(n−r)!. With repetition, each of the r positions has n independent choices, so P(n,r) = nʳ. A combination is an unordered selection of r items from n. The number of combinations is denoted C(n,r), nCr, or — the standard notation in modern mathematics — the binomial coefficient (n choose r), written (n r). Without repetition, C(n,r) = n!/(r!(n−r)!). With repetition (the multiset coefficient), C(n,r) = C(n+r−1, r) = (n+r−1)!/(r!(n−1)!), which counts the number of ways to place r indistinguishable balls into n distinguishable boxes — equivalently, the number of weak compositions of r into n parts. The factorial n! is defined for non-negative integers by 0! = 1 and n! = n × (n−1)! for n ≥ 1. The convention 0! = 1 is forced by the empty product (there is exactly one way to arrange nothing, namely doing nothing) and is what makes the binomial coefficient formula work at the boundary cases C(n,0) = C(n,n) = 1. Two facts the calculator's output makes immediate. First, the symmetry C(n,r) = C(n, n−r) — choosing r things to include is the same as choosing n−r things to exclude. Second, Pascal's identity C(n,r) = C(n−1, r−1) + C(n−1, r), which generates Pascal's triangle row by row and is the inductive foundation of the binomial theorem (a + b)ⁿ = Σ_{r=0}^n C(n,r) aⁿ⁻ʳ bʳ. The four cells of the with/without-repetition × ordered/unordered table — n!/(n−r)!, nʳ, n!/(r!(n−r)!), C(n+r−1, r) — are the entire vocabulary of elementary combinatorics, and almost every counting problem in an introductory probability course reduces to identifying which of the four applies.
How to use this calculator.
- Enter n — the total number of items in the pool. For a standard deck this is 52; for a 6/49 lottery it is 49; for the English alphabet it is 26. Any non-negative integer up to 170 is accepted (170 is the largest n for which n! fits inside an IEEE 754 double; 171! overflows to Infinity).
- Enter r — the number of items you are choosing or arranging. For a five-card poker hand this is 5; for a 6/49 ticket it is 6; for a three-letter password it is 3. r must be a non-negative integer. Without repetition r must be ≤ n; with repetition r may exceed n.
- Toggle 'Allow repetition?'. Choose 'No' for selections where each item can appear at most once — lotteries, raffles, committees, podium finishes, poker hands. Choose 'Yes' for selections with replacement — dice rolls, passwords where characters can repeat, ice-cream-scoop combinations where the same flavour can be picked twice.
- Read the primary result — the number of combinations C(n,r). For inputs n = 49, r = 6, no repetition this is 13,983,816, the famous denominator of the 6/49 lottery odds. The display switches to scientific notation automatically for results above about 10¹⁵.
- Compare combinations against permutations in the results panel. Without repetition the ratio P(n,r) / C(n,r) is exactly r! — that is the number of orderings of any chosen r-element subset, and it is what you 'divide out' to convert permutations into combinations. For r = 6 the ratio is 6! = 720.
- Use the factorial outputs n! and r! to sanity-check the formula by hand or to feed downstream calculations (multinomial coefficients, Poisson approximations, Stirling-formula estimates). Recall that 0! = 1, 1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120, and that factorials roughly double in size with each unit increase in n by the time n exceeds 10.
- For inputs beyond n = 170 use a computer-algebra system (SageMath, PARI/GP, Mathematica, Python's math.factorial) which supports arbitrary-precision integers. The Quanta engine internally uses BigInt and would handle any n, but the JSON output type is Number and we cap at the double-precision overflow boundary by design.
The formula.
Start from the fundamental counting principle: if a process has k independent stages with n₁, n₂, …, n_k choices at each stage, the total number of outcomes is the product n₁ · n₂ · … · n_k. From this single rule every formula on the page is derived. Permutation without repetition. Choose r items in order from a pool of n with no repeats. The first position has n choices; the second has n−1 remaining; the third has n−2; and so on down to the r-th position, which has n−r+1 remaining choices. Multiplying gives P(n,r) = n · (n−1) · (n−2) · … · (n−r+1). Writing the top of the product as n! and dividing by the missing tail (n−r)! that we did not use gives the closed form P(n,r) = n!/(n−r)!. The special case r = n is the number of full arrangements of all n items: P(n,n) = n!/0! = n!, and this is why factorial is the 'arrangement number' of n distinguishable objects. Permutation with repetition. Each of the r positions has n independent choices because picking an item does not remove it from the pool. The fundamental counting principle gives P(n,r) = n · n · n · … · n (r times) = nʳ. Combination without repetition. The combination is the unordered version of the permutation: we no longer distinguish between the r! different ways an r-element subset can be internally ordered. Two arrangements like (A, B, C) and (B, A, C) count once as a combination but twice as a permutation. Since every r-element combination corresponds to exactly r! orderings — the number of permutations of r distinguishable items — we divide the permutation count by r!: C(n,r) = P(n,r) / r! = n! / (r!(n−r)!). This is the binomial coefficient, written (n r) in modern notation. The 'divide by r!' step is the entire conceptual content of the combination formula. Combination with repetition (multiset coefficient). This is the famous stars-and-bars argument. Suppose we want to choose r items from n types with repetition allowed (so the result is a multiset, not a set). Represent the choice as a sequence of r stars and n−1 bars: the stars are the items, partitioned into n groups by the bars to indicate how many of each type were chosen. For instance choosing 3 items from 2 types (A or B) where the choice is AAB is encoded as ★★|★. There are r + (n−1) = n + r − 1 symbols in total, and we just need to choose which n−1 of the positions are bars (equivalently which r are stars). That is C(n+r−1, n−1) = C(n+r−1, r). NIST DLMF §26.3.7 lists this formula directly. Why divide out r! for combinations but not for ordered cases? Because the fundamental counting principle counts every distinguishable outcome separately, and ordered cases treat (A, B) and (B, A) as distinguishable. Combinations explicitly identify those as the same outcome, so we must compensate by dividing by the number of orderings — which for r distinct items is exactly r!. This is also why 0! = 1 is the right convention: it makes C(n, 0) = 1 (there is one way to choose nothing) and C(n, n) = 1 (there is one way to choose everything) come out automatically, without a special case. Implementation note. The Quanta engine computes all four formulas in BigInt with the multiplicative variant C(a,b) = ∏ᵢ₌₁ᵇ (a − b + i) / i for binomial coefficients, which avoids computing full factorials for large a and which uses the symmetry C(a,b) = C(a, a−b) to pick the smaller of b and a−b. This keeps intermediate values small and exact, and only the final result is converted to a JavaScript Number for display.
A worked example.
The Canadian Lotto 6/49 and the original UK National Lottery both ask players to choose 6 numbers from {1, 2, …, 49}. The order in which a player marks the six numbers on the ticket does not matter — (3, 17, 23, 29, 31, 47) and (47, 31, 29, 23, 17, 3) win or lose together — and no number can be repeated on a single ticket. This is the textbook setup for a combination without repetition with n = 49 and r = 6. Plug into C(n,r) = n!/(r!(n−r)!): C(49, 6) = 49! / (6! × 43!) = (49 × 48 × 47 × 46 × 45 × 44) / (6 × 5 × 4 × 3 × 2 × 1) = 10,068,347,520 / 720 = 13,983,816. So there are exactly 13,983,816 distinct unordered six-number tickets, and the probability that any single randomly chosen ticket wins the jackpot is 1 / 13,983,816 ≈ 7.15 × 10⁻⁸, or about one in fourteen million. The calculator returns combinations = 13,983,816 as the primary output and reports permutations = P(49, 6) = 49! / 43! = 49 × 48 × 47 × 46 × 45 × 44 = 10,068,347,520. The ratio of permutations to combinations is exactly 10,068,347,520 / 13,983,816 = 720 = 6!, which is the r! factor — the number of ways to internally re-order any chosen six-number subset. The factorial outputs are n! = 49! ≈ 6.08 × 10⁶² and r! = 6! = 720. Compare against the same problem with repetition allowed (a fictional 'replacement lottery' where the same number could be drawn twice): the calculator would return C(49 + 6 − 1, 6) = C(54, 6) = 25,827,165 and P(49, 6) = 49⁶ = 13,841,287,201 — both substantially larger than the no-repetition versions, because allowing repeats expands the set of legal tickets.
Frequently asked questions.
When do I use a permutation versus a combination?
What is 0! and why is it equal to 1?
What is P(n,n) and why is it n!?
What does 'with repetition' mean and when should I use it?
What is the largest n the calculator supports and why?
How are permutations and combinations related to Pascal's triangle?
What is the difference between C(n,r) and C(n+r−1, r)?
Why are lottery odds expressed as C(n,r)?
What is the relationship between factorials and the gamma function?
How are permutations of multisets counted (items with repeated copies)?
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 Quanta's engine, 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.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 313 calculators remain free
- No billing is enabled