Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Combinatorics Calculator

How to use Combinatorics Calculator
  1. Pick a scenario with the ten buttons at the top, from Permutation (Full) to Distribution into Cells; the form and the panel change to match. Learn more about the scenarios
  2. Type the numbers the scenario asks for, such as n and r, in the boxes; the × next to a box clears it. Learn more about the numbers
  3. For identical items or groups, click Add Type or Add Group for another count and fill each one; the counts must add up to n. Learn more about counts and groups
  4. Click Calculate. The result box states the number of ways in a sentence, and a red message appears when a number is missing, negative, or impossible. Learn more about results
  5. The panel under the form shows the formula, what the scenario counts, a worked example and the reasoning, ending with links to the sections and lessons that explain it. Learn more about the panel
  6. Click Reset to clear the boxes and the result of the current scenario. Learn more about Reset

Related Calculators

Calculate various combinatorial scenarios

Permutation (Full)

Explanation

P(n)=n!P(n) = n!

Calculate the number of ways to arrange nn distinct objects in a sequence. Learn more about full permutations · All permutations

Example:

How many ways can you arrange 5 people in a line? 5!=1205! = 120 ways

Why this formula?

For the first position, you have nn choices. For the second position, you have (n−1)(n-1) choices, and so on. This gives us n×(n−1)×(n−2)×⋯×1=n!n \times (n-1) \times (n-2) \times \cdots \times 1 = n!

Read more about full permutations .






Choosing a Scenario

DemoFour of the ten scenarios
Step 0 of 4
The calculator covers ten counting scenarios, picked with the ten buttons at the top. The first five are permutations, where the order of the items matters: Permutation (Full), Permutation with Identical Items, Partial Permutation without Repetition, Permutation with Repetition and Circular Permutation. The other five count selections and distributions, where the order does not matter: Simple Combination, Partition into Groups, Weak Composition, Strong Composition and Distribution into Cells.

Click a button and the form below changes to the boxes that scenario needs: one number nn for a full or circular permutation, nn and rr for a combination or a composition, or a list of counts for identical items and groups. The explanation panel under the form switches at the same time. The selected button is shown in blue.

The page can open on a given scenario through its address: adding ?scenario=6 to the URL opens Simple Combination, which is how the lessons link here. Each scenario keeps its own numbers while you look at another.

How to tell a permutation from a combination, the choice that decides the scenario, is explained in permutations and combinations and distributions.

Entering the Numbers

Demon and r for a combination, and the × button
Step 0 of 5
Every scenario takes whole numbers from 00 upward. The first box is nn, the number of items; scenarios that pick or distribute also take rr, the number picked or the number of cells. The placeholder in each box shows a sample value, and the × button next to a box clears it on its own.

Two scenarios take a list of counts. Permutation with Identical Items takes the total nn and one count per type of identical item, added with Add Type; the counts must add up to nn, as for the word BOOK with 44 letters and counts 1,2,11, 2, 1. Partition into Groups takes nn and one size per group, added with Add Group; the sizes must add up to nn. A row of counts has its own × to remove it.

The numbers are checked when you click Calculate: rr cannot exceed nn in a combination, since you cannot pick more items than there are, and counts that do not add up to nn are refused with a message that names the mismatch. For Simple Combination with n=5n = 5 and r=3r = 3 the result is 1010.

What nn and rr stand for in each formula is explained in simple combination.

Calculating and Reading the Result

DemoA result, a message, Reset
Step 0 of 4
Click Calculate and the result box appears under the form. It shows the formula with your numbers, the count, and a sentence that says what was counted: for n=5n = 5 in Permutation (Full), There are 120 ways to arrange 5 distinct objects. Large counts are printed with thousands separators.

Small inputs are computed on this page. Very large ones, where the factorials overflow, are sent to the server, and a count beyond what can be represented is reported as Number too large for calculation; a full permutation accepts nn up to 100100.

Messages appear in red above the result when the input is not usable: Please enter a valid number for an empty or non-numeric box, Please enter a non-negative number for a negative one, r cannot be greater than n in a combination, and a sum mismatch for identical items and groups. Correct the box and click Calculate again.

Reset clears the boxes, the result and the message of the current scenario; the other scenarios keep their numbers. Why 5!5! counts the arrangements of five objects is explained in permutation (full).

The Explanation Panel

DemoThe panel follows the scenario
Step 0 of 4
Under the form of every scenario sits an explanation panel with four parts: the formula in symbols, a description of what the scenario counts, a worked example with real numbers, and the reasoning that derives the formula from the counting principle. The description ends with links to the sections on this page that treat the scenario and its family, and the reasoning ends with a link to the lesson that teaches it.

The panel follows the scenario buttons, not the numbers: it shows P(n,r)=n!/(n−r)!P(n, r) = n! / (n - r)! for a partial permutation, nrn^r for a permutation with repetition, the multinomial coefficient for a partition into groups, and rnr^n for a distribution into cells, whatever you have typed. The result box, by contrast, shows the formula with your own numbers.

Read the example first when a scenario is new: it names a situation, people in a line, a PIN, candies among children, and that is the quickest way to recognise which scenario a problem belongs to.

The principle every panel rests on, multiplying the choices made one after another, is explained in permutations.

Permutations

A permutation is an arrangement in which the order matters: the line A,B,CA, B, C differs from C,B,AC, B, A. Counting them rests on the multiplication rule: with nn choices for the first place, n−1n - 1 for the second and so on, the choices multiply. The five permutation scenarios of the calculator are variations on that rule.

Permutation (full) arranges all nn distinct items, n!n! ways. Permutation with identical items divides by the factorials of the repeated counts. Partial permutation without repetition arranges only rr of the nn items, n!/(n−r)!n! / (n - r)! ways. Permutation with repetition lets every place take any of the nn items, nrn^r ways. Circular permutation seats nn items in a ring, (n−1)!(n - 1)! ways.

The common mistake is to count a selection as a permutation: a committee of three from five is one combination, but the same three people in three ranked positions are six permutations.

See the logic behind permutations, types of permutations and the multiplication rule.

Permutation (Full)

The number of ways to arrange nn distinct objects in a row is n!=n×(n−1)×⋯×1n! = n \times (n - 1) \times \cdots \times 1: the first place has nn choices, the second n−1n - 1, and the choices multiply. Five people in a line can stand in 5!=1205! = 120 orders, four books on a shelf in 4!=244! = 24.

The factorial grows fast: 7!=50407! = 5040, 10!=362880010! = 3628800, and the calculator switches to the server beyond the numbers it can hold locally; it accepts nn up to 100100. By definition 0!=10! = 1: there is exactly one way to arrange nothing.

The common mistake is to add the choices instead of multiplying them, which gives 5+4+3+2+1=155 + 4 + 3 + 2 + 1 = 15 instead of 120120.

See permutation (full) and, for the factorial itself, what are factorials.

Permutation with Identical Items

When some of the nn objects are identical, arrangements that only swap identical objects look the same and must be counted once. With counts n1,n2,…,nkn_1, n_2, \ldots, n_k of each kind, the number of distinct arrangements is n!n1! n2!⋯nk!\dfrac{n!}{n_1! \, n_2! \cdots n_k!}.

The letters of BOOK, with two O's, give 4!1! 2! 1!=242=12\dfrac{4!}{1! \, 2! \, 1!} = \dfrac{24}{2} = 12 distinct words. MISSISSIPPI, with 1111 letters, four S, four I and two P, gives 11!4! 4! 2!=34650\dfrac{11!}{4! \, 4! \, 2!} = 34650. Each division removes the swaps within one kind of letter.

In the calculator, type the total nn and one count per kind with Add Type; the counts must add up to nn. The common mistake is to list only the repeated kinds: a kind that occurs once still counts 11, and the total must match.

See permutation with identical items.

Partial Permutation without Repetition

Picking rr items from nn and arranging them in order, each item used at most once, can be done in P(n,r)=n!(n−r)!=n(n−1)⋯(n−r+1)P(n, r) = \dfrac{n!}{(n - r)!} = n (n - 1) \cdots (n - r + 1) ways. The product has rr factors, starting at nn and going down by one.

Three podium places from five runners: P(5,3)=5×4×3=60P(5, 3) = 5 \times 4 \times 3 = 60. Two officers, a chair and a secretary, from six members: P(6,2)=30P(6, 2) = 30. With r=nr = n the formula is the full permutation, n!n!.

The common mistake is to use this count when the order does not matter: the 6060 podiums become 1010 committees once the ranking is dropped, which is the combination C(5,3)C(5, 3).

See partial permutation without repetition.

Permutation with Repetition

When each of rr places can hold any of nn items and an item may be used again, the places are independent and the count is nrn^r. A four-digit PIN from the ten digits allows 104=1000010^4 = 10000 codes; a three-letter code from 2626 letters allows 263=1757626^3 = 17576.

The exponent is the number of places, the base the number of choices per place; the calculator's boxes are nn for the items and rr for the places. The count equals the distribution into cells with the roles of items and cells swapped.

The common mistake is to use n!n! or P(n,r)P(n, r), which forbid repeats: a PIN may repeat a digit, so 10×9×8×7=504010 \times 9 \times 8 \times 7 = 5040 would be the count of PINs with four different digits only.

See permutation with repetition.

Circular Permutation

Seating nn distinct people around a round table gives (n−1)!(n - 1)! arrangements, because turning the whole table does not create a new seating: fix one person and arrange the other n−1n - 1 relative to them. Six people have (6−1)!=120(6 - 1)! = 120 seatings, five people 4!=244! = 24.

If the table can also be flipped, so that mirror images count as the same, the number halves to (n−1)!/2(n - 1)! / 2, which is the count for a bracelet of beads; the calculator uses the rotation rule only.

The common mistake is to use n!n! for a circle; the nn rotations of each seating are the same seating, which is where the division by nn comes from.

See circular permutation.

Combinations and Distributions

A combination is a selection in which the order does not matter: the committee {A,B,C}\{A, B, C\} is the same committee however it is listed. The number of ways to choose rr of nn items is C(n,r)=n!r! (n−r)!C(n, r) = \dfrac{n!}{r! \, (n - r)!}, which is the partial permutation P(n,r)P(n, r) divided by the r!r! orders of each selection.

The calculator's five scenarios in this family count selections and placements. Simple combination chooses rr items. Partition into groups splits nn distinct items into labelled groups of given sizes. Weak composition and strong composition share nn identical items among rr cells, with or without empty cells. Distribution into cells places nn distinct items into rr cells with no limit per cell.

The key question for each is whether the items are distinct or identical and whether the cells are labelled; the answers decide between rnr^n, the multinomial coefficient and stars and bars.

See types of combinations, permutations and combinations and the binomial coefficient.

Simple Combination

Choosing rr items from nn without regard to order can be done in C(n,r)=n!r! (n−r)!C(n, r) = \dfrac{n!}{r! \, (n - r)!} ways, also written (nr)\binom{n}{r} and read "n choose r". A committee of 33 from 55 people: C(5,3)=1206×2=10C(5, 3) = \dfrac{120}{6 \times 2} = 10. A lottery pick of 44 numbers from 1010: C(10,4)=210C(10, 4) = 210.

Useful facts: C(n,r)=C(n,n−r)C(n, r) = C(n, n - r), so choosing 33 of 55 equals leaving out 22 of 55; C(n,0)=C(n,n)=1C(n, 0) = C(n, n) = 1; and the values are the rows of Pascal's triangle, each the sum of the two above it.

The calculator refuses r>nr > n with a message, since you cannot pick more items than there are. The common mistake is to forget the division by r!r! and report P(n,r)P(n, r), which counts ordered picks.

See simple combinations and definition of the binomial coefficient.

Partition into Groups

Splitting nn distinct items into labelled groups of sizes n1,n2,…,nrn_1, n_2, \ldots, n_r with n1+n2+⋯+nr=nn_1 + n_2 + \cdots + n_r = n can be done in (nn1,n2,…,nr)=n!n1! n2!⋯nr!\binom{n}{n_1, n_2, \ldots, n_r} = \dfrac{n!}{n_1! \, n_2! \cdots n_r!} ways, the multinomial coefficient. Ten students into a classroom group of 33, a playground group of 44 and a gym group of 33: 10!3! 4! 3!=4200\dfrac{10!}{3! \, 4! \, 3!} = 4200.

The formula is a chain of combinations: choose the first group, C(10,3)C(10, 3), then the second from the rest, C(7,4)C(7, 4), then the last, C(3,3)C(3, 3), and multiply: 120×35×1=4200120 \times 35 \times 1 = 4200. With two groups it is the ordinary binomial coefficient.

In the calculator, type nn and one size per group with Add Group; the sizes must add up to nn. The common mistake is to treat unlabelled groups of equal size as labelled: two teams of 55 from 1010 players are C(10,5)/2=126C(10, 5) / 2 = 126 pairings, not 252252.

See partition into groups and the multinomial coefficient.

Weak Composition

Sharing nn identical items among rr labelled cells, where a cell may stay empty, can be done in C(n+r−1,r−1)C(n + r - 1, r - 1) ways. Five identical candies among three children: C(7,2)=21C(7, 2) = 21; the same count gives the non-negative integer solutions of x1+x2+x3=5x_1 + x_2 + x_3 = 5.

The count comes from stars and bars: write the nn items as stars and separate the cells with r−1r - 1 bars; every arrangement of the n+r−1n + r - 1 symbols is one distribution, and choosing where the bars go is C(n+r−1,r−1)C(n + r - 1, r - 1). For 55 candies and 33 children, one arrangement is ⋆⋆∣⋆∣⋆⋆\star\star | \star | \star\star, meaning 2,1,22, 1, 2.

The common mistake is to treat the candies as distinct and answer 35=2433^5 = 243; that is the distribution into cells, a different scenario.

See weak composition.

Strong Composition

Sharing nn identical items among rr labelled cells so that every cell gets at least one can be done in C(n−1,r−1)C(n - 1, r - 1) ways. Five identical tasks among three team members, nobody idle: C(4,2)=6C(4, 2) = 6; these are the positive integer solutions of x1+x2+x3=5x_1 + x_2 + x_3 = 5.

The count follows from the weak composition: hand one item to each cell first, which leaves n−rn - r items to share freely among rr cells, C(n−r+r−1,r−1)=C(n−1,r−1)C(n - r + r - 1, r - 1) = C(n - 1, r - 1) ways. Equivalently, place r−1r - 1 bars in the n−1n - 1 gaps between the stars.

The count is 00 when n<rn < r, since there are not enough items to fill every cell. The common mistake is to use the weak formula, which allows empty cells: 2121 instead of 66 for the tasks.

See strong composition.

Distribution into Cells

Placing nn distinct items into rr labelled cells, any number per cell, can be done in rnr^n ways: each item chooses its cell independently. Three different tasks on two days: 23=82^3 = 8 schedules. Four distinct letters into three mailboxes: 34=813^4 = 81.

The scenario is the mirror image of the permutation with repetition: there the places choose items, here the items choose cells; both counts are a power. It also counts the functions from an nn-element set to an rr-element set.

The common mistake is to use it for identical items: three identical tasks on two days are only 44 schedules, a weak composition, because the tasks cannot be told apart.

See distribution into cells.