\documentclass{article}

\usepackage{fullpage}
\usepackage{amssymb}
\usepackage{tikz}

% Peano Curve of Polya
\newcounter{polyax}
\newcounter{polyay}
\newcounter{polyaz}
\newcounter{polyap}

\newcommand{\polyafig}[3]{
  \coordinate (p0) at (#1);
  \coordinate (p1) at +(0:#2);
  \coordinate (p2) at (intersection cs:
    first line={(p0)--+(60:1)},
    second line={(p1)--($(p1)!1!150:(p0)$)});
  \draw (p0) -- (p1) -- (p2) --cycle;

  \coordinate (p3) at ($(p0)!(p2)!(p1)$);
  \draw[densely dotted] (p2) -- (p3);

  \setcounter{polyax}{0}
  \setcounter{polyay}{2}
  \setcounter{polyaz}{1}
  \setcounter{polyap}{3}

  \foreach \d in {#3} {
    \pgfmathtruncatemacro{\x}{\thepolyax}
    \pgfmathtruncatemacro{\y}{\thepolyay}
    \pgfmathtruncatemacro{\z}{\thepolyaz}

    \ifthenelse{\equal{\d}{1}}{
      \pgfmathtruncatemacro{\xx}{\y}
      \pgfmathtruncatemacro{\zz}{\z}
    }{
      \pgfmathtruncatemacro{\xx}{\x}
      \pgfmathtruncatemacro{\zz}{\y}
    }
    \pgfmathtruncatemacro{\yy}{\y+1}

    \pgfmathtruncatemacro{\v}{\yy+1}
    \coordinate (p\v) at
      ($(p\xx)!(p\yy)!(p\zz)$);
    \draw[densely dotted] (p\yy) -- (p\v);

    \setcounter{polyax}{\xx}
    \setcounter{polyay}{\yy}
    \setcounter{polyaz}{\zz}
    \setcounter{polyap}{\v}
  }
}

\title{The Peano Curve of P\'olya}
\author{}
\date{}

\begin{document}
\maketitle

A \emph{Peano Curve} is a curve which hits every point in a two-dimensional
object.  Recall that a curve is a continuous function
\[
f : [0,1] \to \mathbb{R}^2.
\]
A famous example of such a curve is due to George P\'olya, which fills a
right-angled triangle.  For $x \in [0,1)$, let $\{a_n\}^\infty_{n=0}$ be the
sequence of digits after the decimal point in its binary expansion.  If there
are multiple binary expansions, either will do (the result is the same).

\end{document}
