Choose what to count, then enter the number of kinds n and the number of items r (or a word, for rearranging letters). The formula below is linked to the input fields, so you can also edit the numbers directly in it.
Table of Contents
-
What you can do on this page
-
What is this calculation used for?
-
How to Use
-
Formulas and figures
-
Permutations with repetition \({}_{n}\Pi_{r}\) (arranging \(r\) items, repeats allowed)
-
Combinations with repetition \({}_{n}\mathrm{H}_{r}\) (choosing \(r\) items, repeats allowed)
-
Distinguishable permutations (rearranging items that include identical ones)
-
Which formula should you use? (arrange or just choose × repeats allowed or not)
-
-
Symbols and terms
-
Good to know before you start
-
How to calculate it in Excel
-
How to calculate it in Google Sheets
-
How to calculate it in Python
-
How to write it in LaTeX and other math languages (copy and paste)
-
How to have ChatGPT do the calculation
-
DataChef Features
-
Related Features
-
NumberChef Calculators List
What you can do on this page
- Find the permutations with repetition \({}_{n}\Pi_{r} = n^{r}\), arranging \(r\) items from \(n\) kinds when the same kind can be used any number of times (example - a 4-digit PIN made from the 10 digits 0 to 9)
- Find the combinations with repetition \({}_{n}\mathrm{H}_{r} = {}_{n+r-1}\mathrm{C}_{r}\), choosing \(r\) items when the same kind can be chosen any number of times (example - buying 5 bottles from 3 kinds of juice)
- Just type in a word such as "TOMATO" to count the ways to rearrange letters that include repeats (distinguishable permutations, up to 30 letters)
- Not sure whether to use \(n^{r}\), \({}_{n}\mathrm{H}_{r}\), \({}_{n}\mathrm{P}_{r}\) or \({}_{n}\mathrm{C}_{r}\)? A decision chart based on "Does order matter?" and "Can the same item be chosen again?" is included
- Answers are shown with every digit, no rounding, even with dozens of digits. For long answers, an approximate value such as \(1.2345 \times 10^{18}\) is added
- Diagrams of combinations with repetition using circles and bars (stars and bars), and copy-and-paste formulas for Excel, Google Sheets and Python, are also on this page
What is this calculation used for?
A 4-digit PIN made from the 10 digits 0 to 9, where the same digit can be used any number of times, has \(10^{4} = 10{,}000\) possibilities. Each extra digit multiplies that by 10, so 6 digits give 1 million.
A password that can use 62 kinds of characters (capital letters, small letters and digits) has \(62^{8} = 218{,}340{,}105{,}584{,}896\) possibilities with 8 characters (about 218 trillion). The permutations with repetition formula lets you compare how much "more kinds of characters" and "a longer password" each help.
Computers represent information with just 2 kinds of symbols, 0 and 1. A byte, a row of 8 of them, can show \(2^{8} = 256\) patterns. That is why a byte is said to have 256 levels.
Full color, with 8 bits each for red, green and blue, gives \(2^{24} = 16{,}777{,}216\) colors, about 16.7 million. The number of screen colors, the bit depth of audio, the number of IP addresses and so on, the "how many can it represent" of every digital device, comes down to permutations with repetition.
DNA is made of 4 kinds of bases, A, T, G and C, and each group of 3 in a row (a codon) stands for 1 amino acid used to build the body. The same base can repeat, so there are \(4^{3} = 64\) kinds of codons.
The body uses 20 kinds of amino acids, and groups of 2 would give only \(4^{2} = 16\), which is not enough. Permutations with repetition confirm why groups of 3 are enough for life to work.
Making a box of a dozen donuts from 5 kinds, with any number of each kind allowed, can be done in \({}_{5}\mathrm{H}_{12} = {}_{16}\mathrm{C}_{12} = 1{,}820\) ways, since order does not matter (combinations with repetition).
Counting orders or inventory breakdowns of "how many of which product" is the same kind of calculation. You can estimate with real numbers, not just a feeling, how many more patterns you need to manage when you add one more product.
On a grid of city blocks, the number of shortest paths that go 3 blocks right and 2 blocks up is the same as the number of rearrangements of the 5 letters "R, R, R, U, U", so it is \(\dfrac{5!}{3!\,2!} = 10\). Distinguishable permutations work directly here.
This calculation is the basis for estimating the number of possible delivery routes or wiring patterns on a circuit board, and it shows in numbers how explosively the options grow as the grid gets larger.
Formulas and figures
Symbols and terms
Symbols
| \(n\) | en | The number of kinds you choose from. (Example - choosing from 3 kinds of juice, \(n = 3\); using the digits 0 to 9, \(n = 10\).) The letter \(n\), for "number", is often used for counts. Only in distinguishable permutations \(\dfrac{n!}{p!\,q!\cdots}\) does it mean something else: the total number of items to arrange ("TOMATO" has 4 kinds of letters, but \(n = 6\)). |
| \(r\) | ar | The number of items you choose (or arrange) with repeats allowed. (Example - buying 5 bottles of juice, \(r = 5\); a 4-digit PIN, \(r = 4\).) It sits in the same position as in the permutation and combination symbols \({}_{n}\mathrm{P}_{r}\) and \({}_{n}\mathrm{C}_{r}\). |
| \(n!\) | n factorial | The product of all the whole numbers from \(n\) down to \(1\). It is the number of ways to arrange all \(n\) items in a row. By definition, \(0! = 1\). (Example - \(4! = 4 \times 3 \times 2 \times 1 = 24\)) |
| \({}_{n}\Pi_{r}\) | n pi r | Permutations with repetition: the number of ways to choose \(r\) items from \(n\) kinds with repeats allowed and arrange them in order. Its value is \(n^{r}\). \(\Pi\) is the capital Greek letter pi, which stands for a product and matches the P in "product". Most US textbooks just write \(n^{r}\) without this symbol, so follow the notation used in your class. |
| \({}_{n}\mathrm{H}_{r}\) | n H r | Combinations with repetition: the number of ways to choose \(r\) items from \(n\) kinds with repeats allowed, where order does not matter. Its value is \({}_{n+r-1}\mathrm{C}_{r}\). The \(\mathrm{H}\) is said to come from "homogeneous", as in the collection of all terms of the same degree. This symbol is rarely seen in US textbooks, which write \(\binom{n+r-1}{r}\) instead. |
| \({}_{n}\mathrm{P}_{r}\) | n P r | Permutations: the number of ways to choose \(r\) of \(n\) items and put them in order, where an item cannot be chosen again once it is picked. P stands for "permutation". |
| \({}_{n}\mathrm{C}_{r}\) | n C r | Combinations: the number of ways to choose \(r\) of \(n\) items, where an item cannot be chosen again once it is picked and order does not matter. C stands for "combination". |
| \(N\) | capital N | On this page, the letter for the number of distinguishable permutations. It is the capital first letter of "number" and is often used for a total you want to find. |
| \(p,\ q\) | p, q | In distinguishable permutations, the letters for how many copies of each identical item there are. (Example - in "TOMATO", T appears \(p = 2\) times, O \(q = 2\) times, M once and A once.) With 3 or more kinds, continue with \(p,\ q,\ r,\ \dots\) (this \(r\) is not the "number of items \(r\)"). They always add up to \(p + q + r + \cdots = n\), the total number of items to arrange. |
| \(\bigcirc\) and \(|\) | circle and bar | The symbols used to count combinations with repetition (a method known as "stars and bars"). A circle ○ is one item chosen, and a bar \(|\) is a boundary between kinds. ○○|○|○○ means 2 of the first kind, 1 of the second and 2 of the third. |
Terms
| counting | Finding how many possible outcomes there are in total. Permutations, combinations and their versions with repetition are all tools for counting efficiently. |
| repetition | The same item appearing two or more times. In this topic, it means that the same item may be chosen two or more times. It is also described as choosing "with replacement". |
| permutation with repetition | An arrangement of \(r\) items chosen from \(n\) kinds, where the same kind can be chosen any number of times and order matters. There are \(n^{r}\) of them, written \({}_{n}\Pi_{r}\) as a symbol. |
| combination with repetition | A selection of \(r\) items from \(n\) kinds, where the same kind can be chosen any number of times and order does not matter. There are \({}_{n}\mathrm{H}_{r} = {}_{n+r-1}\mathrm{C}_{r}\) of them. |
| distinguishable permutation | An arrangement of all \(n\) items when some of them are identical, as in "TOMATO". There are \(\dfrac{n!}{p!\,q!\cdots}\) of them: you divide by the reorderings of identical items to remove the repeats. Also called a permutation with identical items. |
| permutation | A way to choose \(r\) of \(n\) items and put them in a row, where order matters. The symbol is \({}_{n}\mathrm{P}_{r}\), and an item cannot be chosen again once it is picked. |
| combination | A way to choose \(r\) of \(n\) items where order does not matter. The symbol is \({}_{n}\mathrm{C}_{r}\), and an item cannot be chosen again once it is picked. |
| factorial | Multiplying all the whole numbers from \(n\) down to \(1\). The symbol is \(n!\), and it gives the number of ways to arrange all \(n\) items. |
| stars and bars | The method of counting combinations with repetition with symbols: a bar \(|\) marks each boundary between kinds, and a star (a circle ○ on this page) marks each item. Separating \(n\) kinds takes \(n-1\) bars, so the problem becomes choosing the places for the circles out of \(n+r-1\) places. |
| multinomial coefficient | Another name for the number of distinguishable permutations, \(\dfrac{n!}{p!\,q!\cdots}\). The name comes from the fact that the coefficients you get when you expand \((a+b+c)^{n}\) have this form. |
| tree diagram | A branching diagram that lists every possible outcome, so you count each one exactly once. Permutations with repetition correspond to a tree where every branch splits into the same number of branches. |
| shortest path | On a grid of streets, a route to the destination with no detours. The number of shortest paths that go \(p\) blocks right and \(q\) blocks up is the distinguishable permutations \(\dfrac{(p+q)!}{p!\,q!}\). |
Good to know before you start
Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.
If you get stuck, going back over the topics in this table is the fastest way forward.
| Multiplication and division (Grades 3–5) |
|
| Powers and exponents (Grades 6–8, Algebra 1) |
|
| Counting outcomes and tree diagrams (Grade 7) |
|
| Factorials (high school, Algebra 2 or Precalculus) |
|
| Permutations and combinations (high school, Algebra 2 or Statistics) |
|
How to calculate it in Excel
| Number of kinds n | 10 |
| Items to arrange r | 4 |
| Permutations with repetition nΠr | =B1^B2 |
| Number of kinds n | 3 |
| Items to choose r | 5 |
| Places for circles and bars | =B1+B2-1 |
| Combinations with repetition nHr | =COMBIN(B3,B2) |
| Total letters n (TOMATO) | 6 |
| Number of Ts | 2 |
| Number of Os | 2 |
| Number of Ms | 1 |
| Number of As | 1 |
| Arrangements N | =FACT(B1)/(FACT(B2)*FACT(B3)*FACT(B4)*FACT(B5)) |
"^" is the power symbol, FACT is the factorial, and COMBIN is the Excel function for combinations (nCr).
The first table is the 4-digit PIN from the 10 digits 0 to 9, and B3 shows 10000.
The second table is buying 5 bottles from 3 kinds of juice. B3 shows 7 (= 3 + 5 − 1) and B4 shows 21.
The third table rearranges "TOMATO", and B6 shows 180. If there are more kinds of repeated letters, multiply in more FACT terms in the denominator. =MULTINOMIAL(B2,B3,B4,B5) also gives the same 180.
Note that Excel keeps only 15 significant digits, so when the answer has 16 or more digits, the last digits are rounded.
How to calculate it in Google Sheets
| Number of kinds n | 10 |
| Items to arrange r | 4 |
| Permutations with repetition nΠr | =B1^B2 |
| Number of kinds n | 3 |
| Items to choose r | 5 |
| Places for circles and bars | =B1+B2-1 |
| Combinations with repetition nHr | =COMBIN(B3,B2) |
| Total letters n (TOMATO) | 6 |
| Number of Ts | 2 |
| Number of Os | 2 |
| Number of Ms | 1 |
| Number of As | 1 |
| Arrangements N | =FACT(B1)/(FACT(B2)*FACT(B3)*FACT(B4)*FACT(B5)) |
Copy the whole table, paste it into cell A1, and change the numbers to fit your situation.
How to calculate it in Python
import math
from collections import Counter
# 1) permutations with repetition (choose r from n kinds with repeats allowed, and order matters)
kinds = 10 # number of kinds n (the 10 digits 0-9)
picks = 4 # number of items to arrange r (4 digits)
repeated_permutations = kinds ** picks
# 2) combinations with repetition (choose r from n kinds with repeats allowed, order does not matter)
juice_kinds = 3 # number of kinds n (3 kinds of juice)
bottles = 5 # number of items to choose r (5 bottles)
repeated_combinations = math.comb(juice_kinds + bottles - 1, bottles)
# 3) distinguishable permutations (rearranging a word with repeated letters)
word = "TOMATO"
letter_counts = Counter(word)
same_item_permutations = math.factorial(len(word))
for count in letter_counts.values():
same_item_permutations //= math.factorial(count)
print(f"Permutations with repetition (arrange {picks} from {kinds} kinds): {repeated_permutations}")
print(f"Combinations with repetition (choose {bottles} from {juice_kinds} kinds): {repeated_combinations}")
print(f"Rearrangements of {word}: {same_item_permutations}")
How to write it in LaTeX and other math languages (copy and paste)
ₙΠᵣ = nʳ
{}_{n}\Pi_{r} = n^{r}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mmultiscripts>
<mi>Π</mi>
<mi>r</mi><none/>
<mprescripts/>
<mi>n</mi><none/>
</mmultiscripts>
<mo>=</mo>
<msup><mi>n</mi><mi>r</mi></msup>
</mrow>
</math>
n^r
n^r
repeatedPermutation := n^r;
repeated_permutation = n^r;
n^r
ₙHᵣ = ₙ₊ᵣ₋₁Cᵣ
{}_{n}\mathrm{H}_{r} = {}_{n+r-1}\mathrm{C}_{r} = \dfrac{(n+r-1)!}{r!\,(n-1)!}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mmultiscripts>
<mi>H</mi>
<mi>r</mi><none/>
<mprescripts/>
<mi>n</mi><none/>
</mmultiscripts>
<mo>=</mo>
<mmultiscripts>
<mi>C</mi>
<mi>r</mi><none/>
<mprescripts/>
<mrow><mi>n</mi><mo>+</mo><mi>r</mi><mo>−</mo><mn>1</mn></mrow><none/>
</mmultiscripts>
</mrow>
</math>
H(n, r) = C(n+r-1, r)
Binomial[n + r - 1, r]
nHr := binomial(n + r - 1, r);
nhr = nchoosek(n + r - 1, r);
H(n,r) = C(n+r−1, r) = (n+r−1)!/(r!(n−1)!)
N = n! ÷ (p! × q! × r! × ⋯)
N = \dfrac{n!}{p!\,q!\,r!\cdots}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>N</mi>
<mo>=</mo>
<mfrac>
<mrow><mi>n</mi><mo>!</mo></mrow>
<mrow>
<mi>p</mi><mo>!</mo>
<mi>q</mi><mo>!</mo>
<mi>r</mi><mo>!</mo>
<mo>⋯</mo>
</mrow>
</mfrac>
</mrow>
</math>
N = (n!)/(p!q!r!cdots)
Multinomial[p, q, r]
N := factorial(n)/(factorial(p)*factorial(q)*factorial(r));
N = factorial(n)/(factorial(p)*factorial(q)*factorial(r));
N = n!/(p!q!r!⋯)
How to have ChatGPT do the calculation
You are a calculation assistant for counting (permutations and combinations). Do the following 3 calculations by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing). 1. How many 4-digit PINs can be made from the 10 digits 0 to 9? (The same digit can be used any number of times.) 2. How many ways are there to buy 5 bottles from 3 kinds of juice, with any number of each kind allowed? (Count only how many of each kind, not the order of choosing.) 3. How many different strings can be made by rearranging the 6 letters of "TOMATO"? For each, say whether you used permutations with repetition, combinations with repetition or distinguishable permutations, explain why, and show the numbers from the execution result. In Python, use the math module (math.comb and math.factorial) and collections.Counter.
How to Use
-
1Enter your numbersType the numbers you want to calculate with into the input fields
-
2CalculatePress the "Calculate" button
-
3Check the resultThe result appears on the spot. The same page also explains the idea behind the calculation and the formula
DataChef Features
No technical knowledge required.
Intuitive and user-friendly operation.
Can be used without registering personal information.
Automatic file deletion by clicking "download".
and rapid file conversion.
No attribution required.
No need to contact us for commercial use permission.
