Cantor Set

Author

Eric W. Weisstein
January 20, 2017

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Fractals/CantorSet.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/CantorSet.html.

©2017 Wolfram Research, Inc. except for portions noted otherwise

Code

CantorSet[n_]:=NestList[Flatten[#/.{1->{1,0,1},0->{0,0,0}}]&,{1},n]

Enumeration

CantorSet[4]//ColumnForm

FromDigits/@CantorSet[4]

FromDigits[#,2]&/@CantorSet[4]

Mod[LegendreP[Range[0,3^6-1],3],3]==CantorSet[6][[-1]]

Plot

CantorPlot[n_,opts___]:=ArrayPlot[MapIndexed[Flatten[Function[bit,Table[bit,{3^(1+n-#2[[1]])}]]/@#1]&,CantorSet[n]],opts,Frame->False]

V5

CantorPlot[5,PixelConstrained->True,ImageSize->500]

CantorPlot[4]

V6

CantorPlot[4]

V11.1

GraphicsColumn[Table[CantorMesh[n],{n,0,4}],Spacings->-350]