Pascal's triangle, coloured by remainder

Every cell is the sum of the two above it. Cells are coloured dark when the number is a multiple of m. Start with m = 2 (even numbers) and then try 3, 5 and 7. Then try 4 or 6 and notice the difference.

What's going on

You do not need the actual numbers to know whether they are multiples of m. The remainder of a sum is the sum of the remainders (then take the remainder again). So the demo builds the whole triangle using only remainders, which is lucky, because row 128 contains numbers with 38 digits.

With m = 2 the light cells (the odd numbers) form the Sierpinski triangle, a shape made of three half-size copies of itself, forever. For any prime p, the cells not divisible by p form a similar self-copying pattern with p(p + 1)/2 copies, each scaled down by a factor of p. Composite m like 4 or 6 give a messier mix of patterns layered on each other.

Row n of Pascal's triangle has exactly as many odd numbers as 2 to the power of (number of 1s in n written in binary). Row 7 is 111 in binary, so all eight of its numbers are odd. Check it.

Sheet: Pascal's triangle.