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)$ / $\binom{n}{r}$ / "$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.
The Build Set
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.
Adjusting n and r
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.
Common combinations:
• n=3,r=2: C(3,2)=3 subsets.
• n=4,r=2: C(4,2)=6 subsets.
• n=4,r=3: C(4,3)=4 subsets.
• n=5,r=2: C(5,2)=10 subsets.
• n=5,r=3: C(5,3)=10 subsets.
• n=5,r=5: C(5,5)=1 — the only size-n subset is the whole set.
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.
Grouping by Smallest Item
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=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).
Each row in the completed area sizes itself to its group's count, so rows shrink as the smallest item gets larger.
Transport Controls
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 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).
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.