Pascal's triangle mod n
Every number is the sum of the two above it. Colour each by its remainder, and fractals appear.
In Pascal's triangle every number is the sum of the two above it, with 1s down both sides. The numbers grow huge fast. But colour each one only by its remainder after dividing by 2, 3 or 5, and a fractal appears: triangles inside triangles, forever.
How it works
What the numbers are. The number in row n, position k, is C(n, k), the number of ways to choose k things from n. The rule C(n, k) = C(n−1, k−1) + C(n−1, k) builds the whole triangle from the 1s on its sides.
Only remainders are needed. The remainder of a sum is the remainder of the sum of the remainders. So the triangle can be built with remainders from the start, and the numbers never get big.
Odd and even make Sierpiński's triangle. Light up the odd numbers and leave the even ones dark. The first 2ᵐ rows form three copies of the first 2ᵐ⁻¹ rows, with an upside-down dark triangle in the middle. Doubling the rows triples the lit cells, so 128 rows hold 3⁷ = 2,187 odd numbers. Keep going and you get the Sierpiński triangle.
Any prime p works the same way. Lucas's theorem says p divides C(n, k) exactly when some digit of k, written in base p, is bigger than the matching digit of n. So the pattern for pᵐ rows is built from copies of the pattern for pᵐ⁻¹ rows, and the number of entries p doesn't divide in the first pᵐ rows is (1 + 2 + … + p)ᵐ. For p = 3 that is 6ᵐ, and for p = 5 it is 15ᵐ.
The same fractal elsewhere. The chaos game draws the Sierpiński triangle with random jumps (No. 022), and Rule 90, a simple cellular automaton, draws it row by row too, because it is the odd-even rule of this triangle.
In the video
No. 079 shows remainders after ÷ 2 on 128 rows (2,187 lit of 8,256), after ÷ 3 on 243 rows (7,776 = 6⁵ lit), and after ÷ 5 on 125 rows (3,375 = 15³ lit). The row counts are powers of the prime, so each picture ends on a complete copy.
