Hacker News new | ask | show | jobs
by hasmanean 1642 days ago
When I was in high school my teacher told me a trick…take Pascal’s triangle and colour the even numbers black and the odd numbers white. You’ll end up with a Sierpinski triangle.

Since Each row of Pascal’s triangle is generated from the row just above it…

P(x,y) = P(x,y-1) + P(x-1,y-1)

and since for any even or odd numbers …

even+even=even, odd+odd=e, o+e=o

so really you can compute the sign of any item in Pascal’s triangle by just checking the sign of the two numbers above it and xoring them.

So you can compute each pixel S(x,y) = xor( S(x,y-1), S(x-1,y-1)

Where the initial row is all 0 with a single 1 in it.

I wrote a program on the Mac II in high school to compute this…it was quite a lot of fun. The process of going from integer to floating point to large integer to single bits was instructive.