Every entry answers a counting question
The triangle looks decorative and behaves like a lookup table. The number sitting in row 5 at position 2 is 10, which is the number of two-person teams you get from five people. Read the same entry as a coefficient and it is the 10 in front of a³b² when you expand (a + b)⁵. Same value, two jobs, and the reason a printed triangle beats a factorial calculation for small numbers is that you never divide anything.
Both indices start at zero in the generator above, since that is how the binomial coefficient is defined and how every textbook writes the recurrence. The apex is row 0. The leftmost entry of any row is position 0.
| What you want | Where to look | Worked case |
|---|---|---|
| Ways to choose k from n | Row n, position k | Row 6 position 3 gives 20 three-card hands from six cards |
| Coefficients of an expansion | Read row n from left to right | Row 4 gives 1, 4, 6, 4, 1 for (a + b)⁴ |
| Total subsets of a set | Add up row n | Row 8 adds to 256, the count of every subset of eight items |
| Coin flip probability | Row n position k, divided by the row sum | 3 heads from 5 flips is 10 over 32, near 31 percent |
| A single large coefficient | Type the row number, click the entry | Row 30 position 15 is 155,117,520 |
The row is a binomial expansion written sideways
Nothing about the triangle is separate from the algebra. Multiply (a + b) by itself n times and the coefficients you collect are exactly row n. The addition rule that builds the triangle is the same bookkeeping you do by hand when you gather like terms, which is why the two never disagree.
| n | Row | Expansion of (a + b)n |
|---|---|---|
| 0 | 1 | 1 |
| 1 | 1 1 | a + b |
| 2 | 1 2 1 | a² + 2ab + b² |
| 3 | 1 3 3 1 | a³ + 3a²b + 3ab² + b³ |
| 4 | 1 4 6 4 1 | a⁴ + 4a³b + 6a²b² + 4ab³ + b⁴ |
| 5 | 1 5 10 10 5 1 | a⁵ + 5a⁴b + 10a³b² + 10a²b³ + 5ab⁴ + b⁵ |
Click any entry in rows 0 through 8 above and the inspector prints the whole expansion for that row. Past row 8 it prints the single term instead, because a 20-term line wraps into unreadable soup on a phone.
Read down a diagonal and a different sequence appears
Rows get the attention, diagonals hold the sequences. The k-th diagonal is the sequence of C(n,k) as n climbs, and each one counts a shape one dimension up from the last.
| Diagonal | First terms | Formula | What it counts |
|---|---|---|---|
| k = 0 | 1, 1, 1, 1, 1 | C(n,0) | One way to pick nothing, at every size |
| k = 1 | 1, 2, 3, 4, 5 | C(n,1) = n | Counting numbers, one pick from n |
| k = 2 | 1, 3, 6, 10, 15 | n(n-1)/2 | Triangular numbers, the handshakes in a room of n |
| k = 3 | 1, 4, 10, 20, 35 | n(n-1)(n-2)/6 | Tetrahedral numbers, cannonballs stacked in a pyramid |
| k = 4 | 1, 5, 15, 35, 70 | C(n,4) | Pentatope numbers, the same idea in four dimensions |
The triangular numbers lens paints the k = 2 diagonal on both sides, since C(n,2) and C(n,n-2) hold equal values. That mirroring is the symmetry rule: choosing 2 people to include is the same act as choosing n-2 to leave out.
Fibonacci hides on the shallow diagonals
The steep diagonals give polynomials. Tilt the angle and you get something else. Start at the left edge of row d and step up one row and right one position, over and over. Add what you land on and the result is a Fibonacci number.
d = 6 C(6,0) + C(5,1) + C(4,2) + C(3,3)1 + 5 + 6 + 1 = 13 d = 7 C(7,0) + C(6,1) + C(5,2) + C(4,3)1 + 6 + 10 + 4 = 21
Written once: the sum of C(d-k, k) over every k that fits is F(d+1). The Fibonacci lens tints alternate bands so the diagonals separate visually, and prints the running sums beneath the buttons. Why it works comes back to the addition rule. Splitting a diagonal into its two feeding diagonals reproduces the same recurrence Fibonacci runs on, one term built from the two before it.
The hockey stick is a running total, not a coincidence
Pick a cell that is not on the left edge. Walk up and left one step, then straight up the diagonal to the outer edge. Everything on that run adds to the cell you started from. The shape of the highlight is a handle and a blade, which is where the name came from.
Target C(7,3) = 35 Run C(2,2) + C(3,2) + C(4,2) + C(5,2) + C(6,2)1 + 3 + 6 + 10 + 15 = 35
Stated in general, the sum of C(i,r) for i running from r up to n equals C(n+1, r+1). The reason is a counting argument rather than an algebraic one. To choose r+1 items from n+1, sort the choices by which item is largest. Fix that largest item at position i+1 and the remaining r come from the i below it, giving C(i,r) choices. Add over every possible largest item and you have covered each selection exactly once. Select the hockey stick lens and click around, and every cell you press redraws the run that feeds it.
Color by remainder and the Sierpinski triangle appears
Set the lens to Remainders with a modulus of 2. Odd entries stay lit, even entries fade, and what remains is the Sierpinski gasket. Raise the depth to 32 and the self-similar holes get obvious.
The modulus accepts 2 through 12, and the prime values are the interesting ones. Try 3, then 5. Composite moduli produce patterns too, though they mix the behavior of the prime factors and read as noisier. Nothing here is an approximation, since the coloring tests the exact big-integer value against the modulus.
Where this generator stops
- Depth caps at 40 rows. The arithmetic would carry on happily, since every value is a JavaScript BigInt and BigInt has no ceiling. Layout is the limit. Row 39 is 40 numbers wide with entries up to 12 digits, and past that the triangle stops looking like a triangle on any screen.
- Nothing is rounded, and nothing is a float. Ordinary JavaScript numbers stay exact to 253, which the central entry passes around row 57. Building on BigInt from the start means the boundary never arrives at this depth, and the export files hold the same digits you see on screen.
- Only whole non-negative rows. The generalized binomial coefficient handles fractional and negative upper values, which is what powers the binomial series for
(1 + x)1/2. That is an infinite series rather than a triangle, so it has no place in a grid of rows. - No aligned printing beyond text export. Screen layout centers each row with flexbox, and the aligned text export pads with spaces. Those are different alignment methods, so a copied block will not line up pixel for pixel with the page.
- Symmetry is drawn, not deduplicated. Half of every row repeats the other half. The generator prints both halves, because folding the triangle in two saves memory and destroys the shape people came here to read.
- Modulus range is 2 to 12. Large moduli need more distinct colors than a page can hold apart, and a reader cannot tell residue 19 from residue 23 by hue.
Everything runs in this tab. The recurrence, the lenses, and the export writers are all JavaScript on the page, so no row depth you type and no cell you click leaves your browser. Load the page, drop the network, and the triangle still builds.
