% --- start of displayed preamble in the book ---
def sierpinski(expr a,b,n)=
  if n=0:
    fill a--(b rotatedabout(a,60))--b--cycle;
  else:
    sierpinski(a,0.5[a,b],n-1);
    sierpinski(0.5[a,b],b,n-1);
    sierpinski(0.5[a,b rotatedabout(a,60)],
               0.5[a rotatedabout(b,-60),b],n-1);
  fi
enddef;
% --- end of displayed preamble in the book ---
defaultfont:="ptmr8r";
warningcheck:=0;
beginfig(1)
sierpinski((0,0),(0,6cm),6);



endfig;
end;
