Audited 26 Jul 2026·Last updated 28 Oct 2026·6 citations·Tier 1·0 uses

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

Non-negative integer with 0 ≤ n ≤ 170. The upper bound is the IEEE 754 double-precision overflow boundary for n! — 171! is larger than Number.MAX_VALUE ≈ 1.8 × 10³⁰⁸. For a lottery like 6/49 this is the size of the ticket pool (49).
Non-negative integer, at most 170 (r! is shown and 171! overflows). When repetition is disallowed, r must be ≤ n; with repetition, r may exceed n (a multiset can repeat the same element) as long as nʳ stays below about 1.8 × 10³⁰⁸. For a 6/49 lottery r = 6.
Allow repetition?
Combinations C(n,r)
13,983,816
Number of unordered selections of r items from n: C(n,r) without repetition, or the multiset count C(n + r − 1, r) with it.
Permutations P(n,r)
10,068,347,520
n! (factorial of n)
6.083 × 10⁶²
r! (factorial of r)
720

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.

  1. 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.
  2. 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.
  3. 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).
  4. 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).
  5. 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.

C(n,r) = n! ⁄ [r!(n − r)!]

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.

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.

r6
allow Repetitionno
n49

Frequently asked questions.

Is a combination lock really a combination?
No, it's a permutation with repetition. The dials must be turned in the right order, and a digit can appear more than once, so a three-dial lock with ten digits per dial has 10³ = 1,000 settings. If it really ignored order, three digits with repeats allowed would give only C(12,3) = 220 distinct settings, and 1-2-3 would open the same lock as 3-2-1.
How can I tell from the wording whether order matters?
Swap two of the chosen items and ask whether the outcome changed. Words like arrange, rank, schedule, or first, second and third point to permutations; choose, select, hand, team and committee point to combinations. Watch for roles: a committee of 3 from 10 people is C(10,3) = 120, but a president, secretary and treasurer from the same 10 is P(10,3) = 720, because the titles make order matter.
Why is there exactly one way to choose nothing?
Because the empty selection is itself a selection, and there is only one of it. That is why C(n,0) = 1 for every n, and why 0! is defined as 1: the product of no numbers is 1, and the rule n! = n × (n − 1)! needs 1! = 1 × 0! to hold. Setting r to 0 returns 1 for both permutations and combinations.
If I buy 100 different lottery tickets, what are my odds?
In a 6/49 game, 100 different tickets cover 100 of the 13,983,816 possible combinations, so the chance that one of them hits the jackpot is 100 ÷ 13,983,816, about 1 in 139,838. Odds improve in direct proportion to the number of distinct tickets, which also means covering every combination would take nearly fourteen million tickets. Buying the same numbers twice adds nothing to the chance of winning.
When should I turn on repetition?
Whenever an item goes back into the pool after being used. Four-digit PINs allow repeats, giving 10⁴ = 10,000 codes; if repeated digits were banned, the count would fall to P(10,4) = 5,040. Dice rolls, letters in a password and scoops of the same flavour all repeat. Cards dealt from a single deck, lottery balls and people chosen for a team do not.
How do I share out identical items, like sweets among children?
That is a stars-and-bars problem, and the inputs feel backwards: n is the number of recipients and r the number of identical items. Ten identical sweets shared among four children, with some children allowed none, is n = 4, r = 10 with repetition on, giving C(13,10) = 286 ways. If every child must get at least one, hand out four first and share the remaining six: n = 4, r = 6.
Why can't I enter n = 365 for the birthday problem?
Because n is capped at 170: n! is one of the outputs, and 365! is far beyond what a double-precision number can hold. P(365,23) on its own is only about 4.220 × 10⁵⁸, but the cap applies to n regardless of r. The birthday answer is easier as a running product anyway: (365/365) × (364/365) × … × (343/365) = 0.4927, so 23 people share a birthday with probability 0.5073.
Why do very large results look rounded?
From 10¹⁵ upward, results are shown in scientific notation to four significant figures. C(100,50) appears as 1.009 × 10²⁹, though the exact value is the 30-digit integer 100,891,344,545,564,193,334,812,497,256. Ordinary double-precision numbers can only hold whole numbers exactly up to 2⁵³, about 9.007 × 10¹⁵, so beyond that range any calculator working in standard floating point is approximating.
How do I count arrangements of a word with repeated letters, like MISSISSIPPI?
Divide the factorial of the total letters by the factorial of each letter's count: 11!/(4! × 4! × 2!) for its four I's, four S's and two P's. The calculator doesn't do this multinomial step in one go, but its factorial outputs supply the parts: n = 11 gives 39,916,800, n = 4 gives 24 and n = 2 gives 2, and 39,916,800 ÷ (24 × 24 × 2) = 34,650 distinct arrangements.
How many ways can people sit around a round table?
Fewer than in a row, because turning everyone one seat to the left gives the same arrangement. Fix one person's seat and arrange the rest: (n − 1)!. Six people can sit in a row in 6! = 720 ways but around a table in 5! = 120. Enter n = 5 to read 120 from the factorial output, or divide the row count by the six possible rotations.

References& sources.

  1. [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. [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. [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. [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. [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. [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
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
Coming soon