Solution (source code)

= Solution

Starting with $x_0=x>0$, the <continued-fraction algorithm> sets
$$
a_n=\lfloor x_n\rfloor,
\qquad
x_{n+1}=\frac1{x_n-a_n}
$$
unless $x_n$ is already an integer. This gives
$$
x=[a_0;a_1,a_2,\ldots].
$$

Every finite continued fraction is rational, since it is built from integers by finitely many additions and reciprocals. Conversely, if $x=p/q$ is rational in lowest terms, then
$$
\frac pq=a_0+\frac rq,
\qquad 0\leq r<q.
$$
When $r\ne0$, the next complete quotient is $q/r$. Thus each step is an application of the Euclidean algorithm and replaces the denominator by a smaller nonnegative remainder. The process must terminate. This proves the <termination criterion for a simple continued fraction>.

For $x=\sqrt3$,
$$
a_0=1,\qquad
x_1=\frac1{\sqrt3-1}=\frac{\sqrt3+1}{2},\qquad a_1=1,
$$
and
$$
x_2=\frac1{x_1-1}=\sqrt3+1,\qquad a_2=2.
$$
Finally,
$$
x_3=\frac1{x_2-2}=\frac1{\sqrt3-1}=x_1,
$$
so the complete quotients repeat. Hence the <continued fraction of the square root of three> is
$$
\boxed{\sqrt3=[1;\overline{1,2}]}.
$$