# Prove the continued fraction of $\sqrt{n}$ has a period.

I want to know the proof that the continued fraction of $$\sqrt{n}$$ has a period.

This question and answer prove that when the continued fraction has a period, it can be represented by quadratic form. However, it doesn't prove that the continued fraction of quadratic form have a period. According to wikipedia, Lagrange prove it.

"Amazingly, Lagrange's discovery implies that the canonical continued fraction expansion of the square root of every non-square integer is periodic"

Does anybody know how to prove this?

1. Show that tail fractions $$x_k=[a_k, a_{k+1},\ldots]$$ of the number $$\sqrt{n}=x=[a_0;a_1,a_2,\ldots]$$ are the roots of a quadratic equation $$Az^2+Bz+C=0$$ with integer coefficients.
2. Show that coefficients $$A$$, $$B$$, $$C$$ are bounded, i.e. $$|A|,|B|,|C|.
3. Since $$A,B,C$$ are integer and bounded, the number of possible equations $$Az^2+Bz+C=0$$ is finite, and so is the number of possible values for $$x_k$$.
4. That means for some $$k,m$$: $$x_k=x_m$$, which means the continued fraction has to repeat itself.
• Thank you. How he get $|ru-ts|=1$?
• By induction you can show that $\begin{pmatrix}p_n&p_{n-1}\\q_n&q_{n-1}\end{pmatrix}=\begin{pmatrix}a_0&1\\1&0\end{pmatrix}\begin{pmatrix}a_1&1\\1&0\end{pmatrix}\cdots\begin{pmatrix}a_n&1\\1&0\end{pmatrix}$. Taking the determinant, you show that $p_nq_{n-1}-p_{n-1}q_n=(-1)^n$ Commented Feb 14, 2020 at 10:47