This tool draws Pascal's triangle as a grid of circular cells, where each entry is the sum of the two numbers above it: C(n,k) = C(n−1,k−1) + C(n−1,k). Every value equals a binomial coefficient n!/(k!(n−k)!), counting the ways to choose k items from n. Beyond the arithmetic, the triangle hides striking structure: colouring cells by parity reveals a fractal Sierpiński triangle, shallow diagonals sum to Fibonacci numbers, and row sums equal powers of two.
The triangle is built row by row from the Pascal recurrence, then rendered on a canvas. A log-scaled "value" colouring shades cells by magnitude; "parity" colours odd versus even entries to expose the Sierpiński fractal; and "mod N" colours each cell by its remainder when divided by N. Optional outlines mark the Fibonacci diagonals, triangular numbers, and powers of two.
Drag the "Rows" slider (3 to 20) to set the triangle's depth. Pick a colour mode with the three buttons; choosing "Mod N" reveals a number input to set the divisor (2 to 20). The checkboxes highlight the Fibonacci diagonal, triangular numbers, and powers of two, and toggle hover inspection. Hover or click any cell to read its C(n,k) value, row, position, and factorial formula.
A cell C(n,k) is odd exactly when, in binary, every bit of k is also set in n — Kummer's and Lucas's theorems link this to the Sierpiński pattern. This is why the parity colouring produces a self-similar fractal rather than a random scatter of odd cells.
Pascal's triangle is a triangular array of numbers in which each entry is the sum of the two entries diagonally above it, with 1s along both edges. The number in row n, position k equals the binomial coefficient C(n,k), so the triangle is a compact table of every coefficient that appears when expanding (a+b) raised to a power.
The simulation uses the recurrence C(n,k) = C(n−1,k−1) + C(n−1,k), adding the two cells above to fill each new row. The same value can be computed directly with the formula n!/(k!(n−k)!), which is shown when you hover or click a cell. Both methods always agree because they count the same thing: the number of ways to choose k items from n.
"Value scale" shades each cell on a logarithmic scale so small and very large numbers are both visible. "Parity" splits cells into odd and even, revealing the Sierpiński triangle. "Mod N" colours each cell by its remainder after dividing by N, where N can be set from 2 to 20; different divisors expose different self-similar patterns.
When you keep only the odd entries, the surviving cells form the Sierpiński triangle, a classic fractal. The reason is Lucas's theorem: C(n,k) is odd only when the binary digits of k never exceed those of n. That bitwise condition repeats at every scale, so the same triangular voids appear again and again as the triangle grows.
Summing the entries along the shallow "rising" diagonals of the triangle produces the Fibonacci sequence 1, 1, 2, 3, 5, 8, and so on, which the Fibonacci highlight outlines. The triangular numbers 1, 3, 6, 10, 15 sit along the third diagonal, and every row of the triangle sums to a power of two, so all three highlighted patterns are exact mathematical identities, not coincidences.