# Do all numbers of the form $\sqrt{n}$ have a periodic continued fraction in the form $[a_0; \overline{a_1, a_2, \cdots, a_k}]$??

After trying out This question, I noticed that the continued fraction of $$\sqrt{n}$$ where $$n$$ is a non-square integer is in the form $$[a_0; \overline{a_1, a_2, \cdots, a_k}]$$, that is to say, that they are in the form $$a_0 + \cfrac{1}{a_1+\cfrac{1}{a_2+\cfrac{\ddots}{\quad\cfrac{\ddots}{\qquad a_k+\cfrac{1}{a_1+\cfrac{1}{a_2+\ddots}}}}}}$$

I was able to show this was true for $$n\leq10000$$. However, I'm not sure how to show this is true.

• mathworld.wolfram.com/PeriodicContinuedFraction.html: “a continued fraction is periodic iff it is a root of a quadratic polynomial.” Jan 19, 2020 at 9:07
• @Martin R Yes, I am aware that the root of a quadratic polynomial is periodic. However, I am specifically asking if for $\sqrt{n}$ the non-periodic part of the periodic continued fraction has length $1$. Also, the Wolfram article does tell me that the square root of a squarefree integer has non-periodic part of periodic continued fraction equal to length $1$, but it does not tell me why, or about non-squarefree integers. Jan 19, 2020 at 9:09
• There is this book by Khinchin as well which states that "any quadratic irrational number has a periodic continued fraction" as Theorem 28. Jan 19, 2020 at 9:51
• Alternatively, check this resource, Diophantine Equations, by Florian Luca, page 12. Proposition 1.5.6. Let $d > 1$ be a rational which is not a perfect square ... Jan 19, 2020 at 11:40
• That was a useful resource. Thank you for providing it for me. Jan 19, 2020 at 13:14

Taking $$a_0 = \left\lfloor \sqrt n \right\rfloor \; .$$ There is a characterization of purely periodic continued fractions; this is due to Galois. Namely, if $$P,Q,D$$ are integers, $$D>0$$ is not a square, define $$\zeta = \frac{P + \sqrt N}{Q}$$ and call its conjugate $$\eta = \frac{P - \sqrt N}{Q}$$ The first result is that $$\zeta$$ has a purely periodic continued fraction if and only if it is reduced, which means both $$\zeta > 1 \; , \; \; \; \; \; -1 < \eta < 0$$ In your example you have $$Q=1,$$ $$a_0 < \sqrt n < 1 + a_0,$$ so $$a_0 - \sqrt n < 0 < 1 + a_0 - \sqrt n,$$ the right hand part giving $$-1 < a_0 - \sqrt n,$$ The conclusion is that $$a_0 + \sqrt n$$ has a purely periodic continued fraction. As this differs in only the first entry, we see that the fraction for $$\sqrt n$$ begins being purely periodic after just the initial partial quotient.
• This is the same answer as Pythagoras. How do you show its continued fraction will be periodic for $k$ large enough ? Jan 20, 2020 at 20:58
• @reuns it turns out that the link, and Hardy and Wright's brief description of purely periodic continued fractions, are a, well, disguised version of Lagrange and Gauss's method for indefinite binary quadratic forms, integer coefficient. Each triple $(A,B,C)$ has the same discriminant $B^2 - 4AC,$ is "reduced" as both $AC < 0, \; B > |A+C|,$ and the forms are neighbors in a chain, $C_{n} = A_{n+1}.$ See Dickson (1929) Introduction to the Theory of Numbers. Or Buell (1989) Binary Quadratic Forms. Jan 22, 2020 at 0:44
The general result is usually referred to Lagrange. Your observation is due to Galois by writing $$\sqrt{n}=[n]+\frac 1 t,$$ where $$t=\frac 1{\sqrt{n}-[n]}>1$$ and its Galois conjugate $$s=1/(-\sqrt{n}-[n])$$ satisfies $$-1 See a proof here: https://planetmath.org/purelyperiodiccontinuedfractions
• Your answer shows that $\sqrt{n}$ is not purely periodic, but how do we show that it has a non-periodic length of length exactly 1? Jan 19, 2020 at 11:02
• $t$ is purely periodic, therefore $\sqrt{n}$ has $a_0=[\sqrt{n}]$ as the non-periodic length. I guess this is exactly the same thing as the other posted answer except that I used $[~]$ to denote the floor function. Jan 19, 2020 at 19:15