The Mode switch at the left of the control bar toggles between ● Balls (numbered coloured balls) and A Letters (letter labels). Learn more about the mode switch
The n stepper (3 to 5) sets the source row and the r stepper (1 to n) sets the subset size; lowering n below r pulls r down with it, and either change resets the build. Learn more about adjusting n and r
Step ▶ moves one ball into the build set, ◀ Back undoes one step, ▶ Play builds every subset, ↺ Reset clears the completed rows, and the Speed slider (0.3 to 3) sets the pace. Learn more about the transport controls
The two lines at the top right of the scene show C(n,r) with its total and the status: Group of the current smallest item with its count, or Complete. Learn more about getting started
The build set has r slots with no position numbers; balls land smallest first along a dotted guide line, and used items dim in the source row. Learn more about the build set
The right panel adds a row for each smallest-item group with its progress and a one-line count of how the rest of the subset is picked. Learn more about the right panel
Press ▶ Play to build all C(n, r) subsets, or Step ▶ to advance one ball at a time. Subsets are unordered — balls are shown in canonical order, smallest first.
● BallsA Letters
n =3?
r =2?
Speed
Simple combinations
C(3, 2) = 3! / (2! · (3−2)!) = 3
Choose r items from n distinct items — order does not matter, no repetition. Each subset is counted r! times among the partial permutations, so C(n, r) = P(n, r) / r! = n! / (r! · (n−r)!).
Combination — an unordered selection of r items from a set of n distinct items, with no item reused. The count is C(n,r)=n!/(r!⋅(n−r)!).
C(n,r) / (rn) / "n choose r" — three notations for the same value, the binomial coefficient. All count the number of size-r subsets of an n-element set.
Order doesn't matter — {A,B,C} and {C,A,B} are the same combination. This is what distinguishes combinations from permutations.
Canonical order — the visual convention for showing each subset: always smallest element first, then in increasing order. This keeps equivalent subsets from looking different on screen.
Smallest-item group — the family of combinations whose smallest element is a given item. The completed section groups results this way. Group sizes vary: the group whose smallest is index i has (r−1n−1−i) subsets.
Build set — the build area for this scenario. Slots have no #1,#2,… labels because position is meaningless inside a set.
Getting Started
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 all n available items.
• A build set in the middle with r unlabeled slots — the absence of numbers signals that order doesn't matter inside a combination.
• A completed section below, where every finished subset is filed under the row matching its smallest element.
To run the visualization:
• Press ▶ Play to auto-build all C(n,r) subsets.
• Press Step ▶ to advance one ball at a time.
• Press ◀ to step backward through the animation.
• Adjust the Speed slider to control how fast play advances.
The header shows the formula C(n,r)=total alongside a live status line such as *Group A: k / size* while building, or *Complete · total / total* when done.
(n, r) = (3, 2), idle, frozen
Two waiting slots with no position numbers — the only build area on these pages with nothing to label, because a subset has no first member.
The frozen frame above is the opening position, and its most eloquent feature is a small absence: the two waiting slots carry no position numbers. Every other build area on these pages labels its slots #1, #2, … — here there is nothing to label, because a subset has no first or second member.
Everything else about the frame is familiar from the ordered tools: same balls, same source row, same machinery. The entire difference between P(n,r) and C(n,r) lives in those missing labels.
The Build Set
DemoUnlabeled slots, smallest first
Step 0 of 5
The build area is labeled *BUILD SET (size r = R)* — set, not sequence, because order doesn't matter. What to watch:
• Empty slot outlines with dashed borders, without# labels. Each slot is just a placeholder for one item in the subset; the slot's left-to-right position carries no meaning.
• Balls land in canonical order — smallest item first — so subsets render consistently and visually equivalent subsets look identical.
• When a ball is in flight from the source to a slot, a dotted guide line traces the trajectory in that ball's color.
• In the source row, an item already used in the current build (or in flight) is dimmed.
• When all r slots are filled, a flash ring briefly pulses around the build set, and the completed subset is copied to the appropriate smallest-item row below.
The absence of position numbers is the visual signature of a combination — a deliberate contrast with the labeled #1,#2,… slots in the permutation visualizers.
(3, 2) mid-build, frozen
The third subset under way: B landed, C on its dotted guide — always smallest-first, a canonical spelling rather than an order.
The frozen frame above catches the third subset mid-build: B has landed, C is riding its dotted guide, and the two completed {A,⋅} subsets already sit filed above. Because balls always land smallest-first, the arrangement being built is not an order — it is a canonical spelling of a set.
Canonical order is a bookkeeping trick, not a mathematical claim: {B,C} and {C,B} are one subset, and the tool simply refuses to draw the second spelling. That refusal, applied everywhere, is exactly the division by r!.
Adjusting n and r
Demon, r and the symmetry
Step 0 of 5
Two steppers in the control bar control the size:
• n sets the size of the source set.
• r sets the subset size. The constraint r≤n is enforced; reducing n below the current r clamps r down automatically.
• n=5,r=5: C(5,5)=1 — the whole set is the only size-n subset.
A useful symmetry to spot: C(n,r)=C(n,n−r). Picking r items to include and picking n−r items to exclude give the same count, which is why C(5,2)=C(5,3)=10.
C(5, 2) complete, frozen
Ten pair-cards — and every pair silently names the triple it leaves behind: C(5, 2) = C(5, 3) by include/exclude symmetry.
The frozen frame above is C(5,2) completed — ten pair-cards — and it is one half of the symmetry stated in the last paragraph. Run C(5,3) next and count again: ten cards, differently shaped. Every pair in this frame silently names the triple it leaves behind, and vice versa.
The include/exclude reading deserves to be more than a mnemonic: choosing who sits on the committee and choosing who stays home are the same decision. Whenever r passes n/2, the smaller complement is the easier count — nobody computes C(49,43) except as C(49,6).
Grouping by Smallest Item
DemoRows by smallest item
Step 0 of 5
The completed section organizes subsets by their smallest element — every subset whose minimum is the same item appears in the same row.
Group sizes vary. If the smallest item has index i (counting from 0), then the other r−1 items must be chosen from the n−1−i items strictly larger than it:
group size at smallest index i=(r−1n−1−i)
For example with n=5,r=3:
• Smallest is item 1: pick 2 from the 4 items above it. (24)=6 subsets.
• Smallest is item 2: pick 2 from 3. (23)=3 subsets.
• Smallest is item 3: pick 2 from 2. (22)=1 subset.
Total: 6+3+1=10=C(5,3). This decomposition is the visual proof of Pascal's identity in action — summing (r−1n−1−i) over valid i values reconstructs (rn), as laid out under related concepts.
Each row in the completed area sizes itself to its group's count, so rows shrink as the smallest item gets larger.
C(5, 3) complete, frozen
Ten triples in a staircase of rows: 6 + 3 + 1 by smallest element — Pascal’s identity drawn as shrinking shelves.
The frozen frame above is that worked example completed: C(5,3) as three rows of 6, 3, and 1 triples. The staircase shape is not decoration — each step down reflects a shrinking pool of larger items to draw from.
Notice also which item never fronts a row: with r=3 from five items, nothing above index 2 can be a minimum, because a smallest element needs at least r−1 items above it. The grouping teaches its own boundary conditions.
When r = n: One Subset
Push r up to n and the choice disappears: taking five items from five leaves nothing to decide. The count collapses to its floor:
C(n,n)=n!⋅0!n!=1
Run it at n=5,r=5 and the completed section holds a single card containing every ball — the whole set, the only subset of full size. The 0!=1 convention quietly holds the denominator together, just as it does at the other extreme C(n,0)=1 (the empty set).
The symmetry C(n,r)=C(n,n−r) frames both extremes at once: choosing everything and choosing nothing are mirror decisions, each with exactly one outcome.
C(5, 5) complete, frozen
One card holding every ball: taking all five from five leaves nothing to decide — the count at its floor of 1.
One is the loneliest count in combinatorics, and it always signals the same thing: no freedom left. Between the two extremes the counts rise and fall along a row of Pascal's triangle, peaking at the middle r≈n/2 — the setting with the most genuine choice.
The single-card run is also the fastest way to sanity-check the tool's grouping logic: with r=n only one smallest-item group can exist (the group of the very first item), and its size formula (n−1n−1)=1 agrees. Boundaries are where formulas either shine or break; this one shines — see the derivation for the general machinery.
Transport Controls
DemoSlow speed, Back, Reset
Step 0 of 5
The control bar offers four transport buttons plus a speed slider:
• ◀ (Step back) — walks the animation one step backward. Useful for re-examining a single subset or pausing mid-build.
• Step ▶ (Step forward) — advances one ball into one unlabeled slot. Stop after each step to read the partial subset.
• ▶ Play / ⏸ Pause — runs the animation continuously until all C(n,r) subsets are built, then auto-pauses.
• ↺ Reset — clears the completed section and starts over from the first subset.
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.
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 smallest-item avatar in each completed group is a circle with the item's number. Best for tracking which subsets share the same minimum visually.
• Letters mode — items appear with letter labels (A, B, C, …). The smallest-item avatar in each group is just the letter, colored to match. Best for reading off the subset as a set like {A,C,D} and connecting to algebraic notation.
The encoding is consistent across the source row, the build set, 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 Simple combinations with the full formula C(n,r)=n!/(r!⋅(n−r)!)=total and a one-line reminder that each subset is counted r! times among partial permutations, so C(n,r)=P(n,r)/r!.
A StepRow is added for each smallest-item group as soon as a subset in that group starts or completes. Each StepRow shows:
• The smallest item as a chip plus its name — for instance, *Smallest item: A*.
• A progress counterk/group size tracking how many subsets in this group have completed.
• A short narration of the structure: *Smallest item is A. Pick the remaining r−1 from B, C, D, and E: (r−14) subsets.* For r=1 the narration says the subset is just the single item; when the smallest is the highest valid index, the subset is fully determined.
When all groups complete, every StepRow shows done with a checkmark, and the counter reaches *total / total*.
What Is a Combination
A combination is an unordered selection of r items from a set of n distinct items, with no item used twice. The count of size-r subsets is the binomial coefficient:
C(n,r)=(rn)=r!⋅(n−r)!n!
The same value is read as *"n choose r"*.
Examples:
• Choosing a committee of 3 from 10 people: C(10,3)=120 committees.
• Number of 5-card poker hands from a 52-card deck: C(52,5)=2,598,960 hands.
• Number of size-2 subsets of {1,2,3,4}: C(4,2)=6, namely {1,2},{1,3},{1,4},{2,3},{2,4},{3,4}.
• Drawing a lottery ticket of 6 numbers from 49: C(49,6)=13,983,816 possible tickets.
The combination is the right model whenever a problem asks which items are chosen but not in what order — and reuse is not allowed.
For deeper coverage, see the combinations section on the combinations theory page.
Deriving C(n,r)
The cleanest derivation goes through the partial permutation. Start by counting ordered selections of r items from n — that's P(n,r)=n!/(n−r)!.
Now ask: how many of those ordered selections correspond to the same unordered subset? Every subset of size r can be arranged in r! different orders, and the partial permutation counts each order separately. So:
C(n,r)=r!P(n,r)=r!⋅(n−r)!n!
Equivalently, by direct counting at the position level:
• If order had mattered, the count would be n×(n−1)×⋯×(n−r+1).
• Because order doesn't matter, divide by the r! permutations of each chosen subset.
The tool visualizes the equivalent decomposition: every subset has a unique smallest element. Group by that smallest. The group whose smallest is index i contributes (r−1n−1−i) subsets — the number of ways to fill the other r−1 slots from the n−1−i larger items. Summing across all valid i values yields (rn).
C(3, 2) complete, frozen
Three subset cards where the ordered tool shows six: each card quietly absorbs the 2! spellings of the same pair.
The frozen frame above is the division made visible at the smallest scale: C(3,2)=3 subsets, where the partial permutation tool shows P(3,2)=6 ordered pairs for the same inputs. Set the two frames side by side and pair them up — AB with BA, AC with CA, BC with CB — exactly 2!=2 ordered spellings collapsing onto each card here.
That two-to-one pairing is the formula. The division by r! is not an algebraic trick but a census of duplicates, and at n=3,r=2 it is small enough to check by pointing.
Related Concepts
Partial permutation without repetition — the ordered companion. Counts ordered selections of r from n. Formula P(n,r)=n!/(n−r)!, related to C(n,r) by P(n,r)=C(n,r)⋅r!.
Combination with repetition — relaxes the no-reuse rule, counting multisets of size r from n types. Formula (rn+r−1).
Binomial theorem — the algebraic context for (rn): the expansion of (x+y)n has coefficients (rn) on xryn−r.
Pascal's triangle — every entry is a binomial coefficient (rn). Adjacent rows satisfy (rn)=(r−1n−1)+(rn−1), the rule that builds the triangle.
Pascal's identity — the smallest-element grouping in this tool gives a direct visual proof: (rn)=∑i(r−1n−1−i) summed over valid smallest indices.
Multinomial coefficient — generalizes (rn) to more than two groups: (k1,k2,…,kmn)=n!/(k1!⋯km!).
Combinatorics calculator — to compute C(n,r) for arbitrary n and r, see the combination calculator.
Circular permutation — arranging the chosen items around a circle instead of leaving them unordered multiplies the count by (r−1)!.
Distribution into cells — choosing which items go in one cell is a combination; repeating the choice cell by cell is the distribution count.
Full permutation — ordering the chosen r items afterwards is what turns C(n,r) into P(n,r).
Partition into groups — a partition into two groups is exactly one combination, and the general case is the multinomial extension.