(*Adapted by Rafael Luís: rafaelluis@netmadeira.com
updated to Mathematica v.10 by Ross Moore *)

Clear[Gasket,disp,newF,G,F,sierp,i,j,k,w,trans,group1,group2];

Gasket[level_Integer?NonNegative]:=Module[{newF,G,F,sierp,i,j,k,trans,group1,group2},
trans={{1/2,0,0,1/2,0,0},{1/2,0,0,1/2,1/2,0},{1/2,0,0,1/2,1/4,N[Sqrt[3]]/4}};
group1[list_]:={{list[[1]],list[[2]]},{list[[3]],list[[4]]}};
group2[list_]:={{list[[5]]},{list[[6]]}};
(disp[0]=Show[Graphics[Polygon[{{0,0},{1/2,Sqrt[3]/2},{1,0}}]],AspectRatio->Automatic]);
F={{0,0},{1/2,Sqrt[3.]/2},{1,0},{0,0}};
G=F;
For[k=1,k<level+1,k++,F=Partition[Flatten[G],2];
G={};
For[i=1,i<(Length[trans]+1),i++,newF=F;
For[j=1,j<(Length[F]+1),j++,(newF=ReplacePart[newF,group1[trans[[i]]].F[[j]]+group2[trans[[i]]],j])
];
G=Append[G,newF];
];
G=Partition[Partition[Flatten[G],2],4];
sierp=Table[Graphics[Polygon[G[[n]]],AspectRatio->Automatic]
,{n,1,Length[G]}];
(disp[k]=Show[sierp,AspectRatio->Automatic]);];
]

Gasket[8];GraphicsGrid[{Table[disp[n],{n,0,2}],Table[disp[n],{n,3,5}],Table[disp[n],{n,6,8}]}]