Sierpinski gasket

Sierpinski gasket from Khan Academy

Pseudo-code

  1. Determine the smallest unit of a square will be. If it reaches that size, then fill it with a solid color.
  2. Otherwise, divide the square into four squares. Recursively draw a Sierpinski gasket on the top-left square, top-right square and bottom-right square.

Implementation