\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=10]
\draw (0,0) rectangle +(1,1);
\fill (1/3,1/3) rectangle +(1/3,1/3);
\foreach \n in {1,2,...,4}
{
	\pgfmathparse{1/3^(\n+1)}\let\a\pgfmathresult
	\pgfmathparse{\a+1/3^\n}\let\b\pgfmathresult
	\pgfmathparse{1-\a}\let\f\pgfmathresult
	\foreach\x in {\a,\b,...,\f} 
	{
		\foreach\y in {\a,\b,...,\f}
		{
			\fill (\x,\y) rectangle +(\a,\a);
		}
	}
}
\end{tikzpicture}
\end{document}