Find the continued fraction of the square root of a given integer How to find the continued fraction of $\sqrt{n}$, for an integer $n$?
I saw a site where they explained it, but it required a calculator. Is it possible to do it without a calculator?  
 A: Let's try, for example, $\sqrt5$:
Since that $2\lt\sqrt5\lt3$, the first term is $2$. Subtract $2$ and invert:
$$
\frac1{\sqrt5-2}=\sqrt5+2
$$
Since $4\le\sqrt5+2\le5$, the next term is $4$. Subtract $4$ and invert:
$$
\frac1{\sqrt5+2-4}=\sqrt5+2
$$
We are at the same point as the previous line. Thus, the continued fraction is
$$
(2;4,4,4,4,\dots)
$$
Let's try $\sqrt3$:
Since $1\lt\sqrt3\lt2$, the first term is $1$. Subtract $1$ and invert:
$$
\frac1{\sqrt3-1}=\frac{\sqrt3+1}{2}
$$
Since $1\lt\frac{\sqrt3+1}{2}\lt2$, the next term is $1$. Subtract $1$ and invert:
$$
\frac2{\sqrt3+1-2}=\sqrt{3}+1
$$
Since $2\lt\sqrt3+1\lt3$, the next term is $2$. Subtract $2$ and invert:
$$
\frac1{\sqrt{3}+1-2}=\frac{\sqrt3+1}2
$$
and we are back where we were two lines ago. Thus, the continued fraction is
$$
(1;1,2,1,2,1,2,\dots)
$$
In general, we may have to go several lines before we get the same remainder. It can be shown that roots of any quadratic polynomial with integer coefficients give a repeating continued fraction. Therefore, we will, at some point, get the same remainder.
A: The key is to find reciprocals, using conjugates.  For example, the reciprocal of $\sqrt{7}-2$ is $\frac{\sqrt{7}+2}3$, which you can check by multiplying those two together.  To start with,
$$\sqrt{7}=2+(\sqrt{7}-2)\\=2+\frac{1}{\frac{\sqrt{7}+2}3}\\=2+\frac{1}{1+\frac{\sqrt{7}-1}3}$$
 Carry on like that.  You will only need to know that $\sqrt{7}$ is between 2 and 3 to get the correct integer at each stage.
A: If your $n$ is not a perfect square, I'll show it with an example. Consider $\sqrt{23}.$ $$\sqrt{23}\approx4.8$$ Here I denote successive irrational by $x_k$ and it's integer part by $a_k.$
$$x_0=\sqrt{23}=4+(\sqrt{23}-4)\rightarrow \,\ a_0=4$$
$$x_1=\dfrac{1}{x_0-a_0}=\dfrac{1}{\sqrt{23}-4}=\dfrac{\sqrt{23}+4}{7}=1+\dfrac{\sqrt{23}-3}{7}\rightarrow \,\,a_1=1$$
$$x_2=\dfrac{1}{x_1-a_1}=\dfrac{7}{\sqrt{23}-3}=\dfrac{\sqrt{23}+3}{2}=3+\dfrac{\sqrt{23}-3}{2}\rightarrow \,\ a_2=3$$
$$x_3=\dfrac{1}{x_2-a_2}=\dfrac{2}{\sqrt{23}-3}=\dfrac{\sqrt{23}+3}{7}=1+\dfrac{\sqrt{23}-4}{7}\rightarrow \,\,a_3=1$$
$$x_4=\dfrac{1}{x_3-a_3}=\dfrac{7}{\sqrt{23}-4}=\sqrt{23}+4=8+(\sqrt{23}-4)\rightarrow \,\,a_4=8$$
If you continue your calculations you can show that $x_5=x_1,$ also $x_6=x_2,\,\ x_7=x_3$ which means that block of integers $1, 3, 1, 8$ repeats indefinitely.
Hence we found the infinite periodic continued fraction of $\sqrt{23}$ with the form $$\sqrt{23}=[4, 1, 3, 1, 8, 1, 3, 1, 8, 1, 3, 1, 8, ...=[4;\overline{1, 3, 1, 8,}].$$  
I think, now you can understand how we could do it.
A: The easiest way to find a continued fraction for $\sqrt{n}$ is to use a generalized continued fraction (continued fractions where the numerator is something besides 1).
Starting from $\sqrt{n}$, partition ${n}$ as the sum of the perfect square which is less than or equal to ${n}$, ${s^{2}}$, and a remainder, ${r}$, like this: $\sqrt{s^{2} + r}$.
The generalized continued fraction of this answer will always be:
$$
\sqrt{s^{2} + r} = s + \frac{r}{2s+\frac{r}{2s+\frac{r}{2s+\frac{r}{2s+\frac{r}{2s+\ddots}}}}}
$$
...or, in Gauss' Kettenbruch notation:
$$
\sqrt{s^{2} + r} = s + \underset{i=1}{\overset{\infty}{\LARGE\mathrm K}}\frac{r}{2s}
$$
For example, what's the generalized continued fraction for $\sqrt{21}$? $\sqrt{21} \ = \ \sqrt{16 + 5} \ = \ \sqrt{4^{2} + 5}$, so the generalized continued fraction is:
$$
\sqrt{21} = 4 + \frac{5}{8+\frac{5}{8+\frac{5}{8+\frac{5}{8+\frac{5}{8+\ddots}}}}}
$$
..or..
$$
\sqrt{21} = 4 + \underset{i=1}{\overset{\infty}{\LARGE\mathrm K}}\frac{5}{8}
$$
Here's how to to verify this in Wolfram|Alpha: http://www.wolframalpha.com/input/?i=%284%2B%28ContinuedFractionK%5B5%2C+8%2C+%7Bi%2C+1%2C+infinity%7D%5D%29%29%5E2
You don't have to choose a perfect square less than or equal to $n$, however. You can choose a perfect square larger than $n$. $\sqrt{21} \ = \ \sqrt{25 - 4} \ = \ \sqrt{5^{2} - 4}$, which becomes:
$$
\sqrt{21} = 5 - \frac{4}{10-\frac{4}{10-\frac{4}{10-\frac{4}{10-\frac{4}{10-\ddots}}}}}
$$
You could even do it this way: $\sqrt{21} \ = \ \sqrt{\pi^{2} + (21 - \pi^{2})}$, which gives the result:
$$
\sqrt{21} = \pi + \frac{21 - \pi^{2}}{2\pi+\frac{21 - \pi^{2}}{2\pi+\frac{21 - \pi^{2}}{2\pi+\frac{21 - \pi^{2}}{2\pi+\frac{21 - \pi^{2}}{2\pi+\ddots}}}}}
$$
For more information on continued fractions and roots, read Manny Sardina's General Method for Extracting Roots using (Folded) Continued Fractions: http://myreckonings.com/Dead_Reckoning/Online/Materials/General%20Method%20for%20Extracting%20Roots.pdf
