The Mode switch toggles ● Balls (colored circles numbered 1, 2, 3 …) and A Letters (tiles A, B, C …); the build state is kept, only the drawing changes. Learn more about the mode switch
n − / + sets the source pool from 3 to 5 items and r − / + the number of slots, capped at 4 for n=3 and 3 for n=4 or 5; raising n can lower r. Learn more about adjusting n and r
▶ Play builds all nr arrangements and stops at the end, Step ▶ moves one ball into one slot, ◀ Back steps backward and ↺ Reset clears the completed rows. Learn more about the transport controls
The header shows nr and the total; the status line under it tracks the first-item step being built and ends at Complete. Learn more about getting started
In the build area each ball flies from the source row into the next slot; the source row never dims, so the same item can land again. Learn more about the build area
Finished arrangements are filed under COMPLETED, one row per first item, each row holding nr−1 cards. Learn more about first-item groups
The right panel adds a row per first item with its progress and how the remaining r−1 positions are filled. Learn more about the right panel
Press ▶ Play to build all nr arrangements, or Step ▶ to advance one ball at a time. Each of r positions can be any of n items — repetition allowed.
● BallsA Letters
n =3?
r =2?
Speed
Permutations with repetition
32 = 3 × 3 = 9
Choose r items from n, with order and repetition allowed — each of r positions is filled independently from the full pool of n. Each step builds the family of arrangements whose first item is fixed.
Permutation with repetition — an ordered arrangement of r items chosen from a pool of n distinct items, with each position filled independently and reuse allowed. The count is nr.
nr — the number of arrangements: n choices for each of r positions, multiplied together. Equivalently, the number of length-r sequences (tuples) over an alphabet of size n.
Unlimited supply — every item in the source set is available for every position, every time. Using an item does not remove it from the source.
Position — a slot in the arrangement, numbered #1 through #r from left to right in the build area.
First-item group — the family of arrangements that share the same item in position #1. There are n such groups, each containing nr−1 arrangements, since the remaining r−1 positions can each be any of n items.
Tuple — a synonym for an ordered r-element sequence with repetition allowed. The output of a Cartesian product of r copies of the source set.
Getting Started
DemoPlay all 3² arrangements
Step 0 of 4
The tool opens with n=3 and r=2, ready to build. The scene splits into three areas:
• A source row at the top showing the n available items, labeled *SOURCE (n = N) — UNLIMITED SUPPLY*.
• A build area in the middle with r slots labeled #1 through #r.
• A completed section below, where every finished arrangement is filed under the row matching its first item.
To run the visualization:
• Press ▶ Play to auto-build all nr arrangements.
• Press Step ▶ to advance one ball at a time.
• Press ◀ Back to step backward through the animation.
• Adjust the Speed slider to control how fast play advances.
The header shows the formula nr=total alongside a live status line such as *Step X (item name): k / nr−1* while building, or *Complete · total / total* when done.
(n, r) = (3, 2), idle, frozen
Three balls under an UNLIMITED SUPPLY banner and two empty slots: a menu to read from, not a stock to spend.
The frozen frame above is the opening position, and one phrase in it does the heavy lifting: UNLIMITED SUPPLY. The source row is not a stock of balls to be spent but a menu to be read from — as many times as there are slots.
That single change of rules is worth an exponent: where drawing without replacement gives shrinking factors n,n−1,n−2,…, the menu gives n every time, and the count becomes nr — the derivation makes it precise.
The Build Area
DemoOne ball at a time
Step 0 of 5
The build area is where one arrangement at a time is constructed. The label reads *BUILD AREA (r = R)* with the current r.
What to watch:
• Empty slot outlines with dashed borders, labeled #1,#2,…,#r from left to right.
• When a ball is in flight from the source row to a slot, a dotted guide line in that ball's color traces the trajectory.
• Each ball lands in its assigned slot and stays put until the arrangement completes.
• The source row never dims. This is the visual signature of repetition: even after an item is used, every copy of it remains fully bright in the source — because the supply is unlimited and the same item can be picked again for the next slot.
• When all r slots are filled, a flash ring briefly pulses around the build area. The completed arrangement is then copied to the appropriate first-item row in the completed section below.
(3, 2) mid-build, frozen
The very first arrangement is a repeat: A sits landed in slot #1 while A flies in again toward #2 — and nothing in the source row dims.
The frozen frame above catches the very first arrangement — and it is already a repeat: A sits landed in slot #1 while A flies in again toward slot #2, its source ball still fully bright. In the no-repetition tools this exact picture is impossible.
The undimmed source is the entire scenario in one visual rule. Nothing is consumed, so nothing constrains the next pick — each slot is an independent choice from the full menu, which is why the factors in the count never shrink.
Adjusting n and r
DemoSteppers n and r
Step 0 of 5
Two steppers in the control bar control the size:
• n sets the size of the source pool — the number of distinct options available at every position.
• r sets the number of positions to fill, capped per n to keep nr animation-manageable.
Reducing n below the current r may also clamp r down automatically when the new n allows a smaller maximum. Changing either value resets the build and refreshes the formula in the header.
Grouping by First Item
The completed section organizes arrangements into first-item groups — every arrangement starting with the same item appears in the same row.
There are exactly n groups (one per item in the source) and each group holds exactly nr−1 arrangements. So the total is:
n×nr−1=nr
This is the visual proof of the n^r formula. Pick any item for position #1: n choices. For each choice, the remaining r−1 positions can each independently be any of n items: nr−1 ways. Multiply.
Each group row in the completed area has:
• A tinted background in a faint version of the group's color.
• A colored accent stripe on the left edge.
• A left-side avatar showing the first item — a colored circle with the item's number in balls mode, or the letter in letters mode.
• Mini arrangement cards, each one a full sequence of r items starting with that first item, possibly including repetitions of that item or any other.
3² complete, frozen
Nine sequences in three rows of three, opening with the doubles AA, BB, CC — cards no repetition-free tool can produce.
The frozen frame above is the default 32=9 completed: three rows of three. Look at the first card of each row — AA, BA, CA — every group opens with a doubled or mixed pair, and the diagonal cards AA, BB, CC are arrangements no other tool on this site can produce.
Nine also splits cleanly against its no-repetition counterpart: of the 9 sequences, 6 are repeat-free (the P(3,2) pairs) and 3 are doubles. The gap between nr and P(n,r) is exactly the arrangements that reuse something.
Sequences versus Permutations: 27 against 6
Set n=3,r=3 and the tool builds all 33=27 sequences of length three. Hidden inside them is a familiar face: exactly 3!=6 of the cards use each item once — they are precisely the full permutations of the three items.
The other 21 cards are what repetition adds: 18 with one item doubled, and 3 triples (AAA, BBB, CCC). The inclusion is strict and instructive:
P(n,r)⊂{sequences}and33P(3,3)=276≈22%
Barely a fifth of all sequences are repeat-free — and that fraction only falls as r grows.
3³ complete, frozen
Twenty-seven length-three sequences; hidden among them, exactly six use each item once — the full permutations as a thin subset.
The shrinking fraction has a famous name in disguise: the probability that a random sequence is repeat-free is the birthday-problem calculation. For birthdays, n=365 and r=23 people already push the repeat-free share below half — the same arithmetic as counting cards in this grid.
Spotting the six permutation cards inside the 27 is a good exercise with the mode switch set to letters: scan for cards where no letter appears twice. The completed grid makes the subset relation physical — the no-repetition world is a thin slice of the with-repetition one.
When r Exceeds n: More Slots Than Items
Set n=3,r=4 and something quietly remarkable happens: the build area has more slots than the source has items. Without repetition this configuration is impossible — after three landings the pool would be empty with a slot still waiting. With unlimited supply it is routine: 34=81 sequences.
The pigeonhole principle adds a guarantee: with four slots and three items, every one of the 81 arrangements contains at least one repeat. There is no repeat-free card anywhere in this grid — the P(3,4) that would count them is 0.
Run it and watch the scale, too: 81 completions is the longest animation the n=3 setting allows, three rows of twenty-seven cards each.
3⁴ complete, frozen
Four slots served by three items: 81 sequences, every single one containing a repeat — a configuration impossible without reuse.
The impossibility on the other side is worth stating precisely: the no-repetition formula n!/(n−r)! needs (n−r)!, and for r>n the factorial of a negative number does not exist — the algebra refuses exactly where the balls run out.
This is the configuration behind every code and identifier in computing: binary strings (n=2) reach any length only because reuse is free. Whenever r>n appears in a counting problem, repetition is not an option being allowed — it is the only way the problem can exist. See what is a permutation with repetition for the real-world catalog.
Transport Controls
The control bar offers four transport buttons plus a speed slider:
• ◀ Back (Step back) — walks the animation one step backward. Useful for re-examining a single arrangement or pausing mid-build.
• Step ▶ (Step forward) — advances one ball into one slot. Stop after each step to read the partial arrangement.
• ▶ Play / ⏸ Pause — runs the animation continuously until all nr arrangements are built, then auto-pauses.
• ↺ Reset — clears the completed section and starts over from the first arrangement.
The Speed slider controls how fast play advances. At higher speeds the fly and land timings shrink proportionally; at slower speeds you can clearly see each ball travel from source to slot and follow the dotted guide line in detail.
Mode Switch
The Mode switch at the start of the control bar toggles how each item is rendered:
• Balls mode (default) — items appear as colored circles. The first-item avatar in each completed group is a circle with the item's number. Best for tracking position and group membership visually, and for spotting repeated colors within an arrangement at a glance.
• Letters mode — items appear with letter labels (A, B, C, …). The first-item avatar in each completed group is just the letter, colored to match. Best for reading off the sequence in each arrangement and matching it to algebraic notation like (A,A,C) where repetition is explicit.
The encoding is consistent across the source row, the build slots, the flying ball, every mini card in the completed grid, and the right-panel narration. Switching modes mid-animation is safe — the build state preserves; only the rendering changes.
Right Panel and Progress
The right panel narrates the build as it unfolds, anchored by the header Permutations with repetition with the full formula nr=n×n×⋯=total.
A StepRow is added for each first-item group as soon as an arrangement in that group starts building or completes. Each StepRow shows:
• The first item as a chip plus its name — for instance, *First item: A*.
• A progress counter like k/nr−1 tracking how many arrangements in this group have completed.
• A short narration of the structure: *Position 1 is locked to A. The remaining r−1 positions are each filled from A, B, or C (repetition allowed) in n×n×⋯=M ways.* When r=1 the narration adjusts: with only one position, the outcome is just the first item alone.
When all groups complete, every StepRow shows done with a checkmark, and the counter reaches *total / total*.
What Is a Permutation with Repetition
A permutation with repetition is an ordered arrangement of r items drawn from a pool of n distinct items, where each position is filled independently and the same item can be reused as many times as needed. The number of such arrangements is:
nr
This is the same as the number of length-r sequences over an alphabet of size n, sometimes called r-tuples or words of length r.
Examples:
• Number of 4-digit PINs from digits 0–9: 104=10,000 codes.
• Number of 3-letter strings over the English alphabet: 263=17,576 strings.
• Outcomes of rolling a 6-sided die 5 times in order: 65=7,776 sequences.
• Binary strings of length 8: 28=256 strings.
The permutation with repetition is the right model whenever positions are filled independently from a fixed pool and reuse is allowed — codes, passwords, function inputs, multiple rolls of the same die. Note the binary-string example especially: eight slots served by just two symbols, an r four times larger than n — something no repetition-free model permits.
For deeper coverage, see the permutation with repetition section on the permutations theory page.
Deriving n^r
Apply the multiplication principle of counting one position at a time. The key difference from the no-repetition case is that the count of available options does not shrink between positions:
• Position #1: any of the n items. n choices.
• Position #2: still any of the n items — the previous pick was returned to the pool. n choices.
• Position #3: again n choices.
• …
• Position #r: n choices.
Multiply r identical factors:
n×n×n×⋯×n=nr
The tool visualizes the equivalent factoring: fix the first item (n ways), then fill the remaining r−1 slots independently from the same pool (nr−1 ways). Every row in the completed section is one of those nfirst-item families, and within each family the leftover positions explore every possible r−1 tuple over the full pool — repetitions of the first item explicitly included.
Counts grow geometrically: 33=27, 34=81, 35=243. Doubling r squares the count.
5³ complete, frozen
The largest run: 125 sequences in five rows of twenty-five, of which only 60 are repeat-free — the exponent at work.
The frozen frame above is the tool's largest run: 53=125 sequences, five rows of twenty-five. Against the P(5,3)=60 of the no-repetition tool, more than half of these arrangements — 65 of them — contain at least one reuse.
The exponent is what makes this the fastest-growing count in the permutation family: linear in n for fixed r, but exponential in r for fixed n. One extra slot multiplies the total by all of n, not by a shrinking remainder — which is why codes and passwords get their strength from length, not alphabet.
Permutation with identical items — distinct arrangements of a multiset where some items are indistinguishable. Formula n!/(k1!⋅k2!⋯).
Circular permutation — arrange items around a circle where rotations are identical. Formula (n−1)!.
Combination with repetition — the unordered companion of the permutation with repetition. Counts multisets of size r from n types, formula (rn+r−1).
Multiplication principle — the foundational counting rule behind nr. With r independent positions and n options for each, the total is the product of all r factors.
Cartesian product — the set-theoretic name for the collection of r-tuples this tool enumerates: {1,…,n}r.
Combinatorics calculator — to compute nr for arbitrary n and r, see the permutation with repetition calculator.
Distribution into cells — assigning each of n distinct items to one of k cells is kn, the same nr counting read the other way round.
Pascal's triangle — the contrast worth seeing: repetition gives powers, while the triangle collects the no-repetition counts.
Weak composition — allowing a part to be zero plays the same role here as allowing an option to be reused.