$\def \leftb{} \def \rightb{}$

In this article we shall see that every whole number can be written as a continued fraction of the form

$$ {k\over\displaystyle 1+ \leftb {\strut k\over \displaystyle 1+ \leftb {\strut k\over \displaystyle 1+ {\strut k\over \displaystyle 1+ ... }}\rightb}\rightb}.$$

Let us start with $k=6$. In the last article we showed you how to evaluate continued fractions.

Using this method with $k=6$ you should get the successive values

$$6, \ {6\over 7}, \ {42\over 13}, \ {78\over 55}, \ {330\over 133}, \ {798\over 463},...$$

Now write these fractions as decimals and you will see that the values are alternately above and below 2. If we continued this sequence we would see the fractions getting closer and closer to 2 and if you know how to do so you might like to write a program to give more terms of this sequence. We shall now show that the value of this infinite continued fraction is actually 2. Let $V$ be the value
of the infinite continued fraction with $k=6$. Then $$V= {6\over 1+V}$$ so that $$V^2+V-6=0.$$ This factorises as $(V-2)(V+3)=0$ so that $V$ (which is positive) must be 2. We have now shown that the number 2 can be written as an infinite continued fraction. It turns out that to write the number 1 as an infinite continued fraction we need to take $k=2$. Following the method given above you will
get the equation $V^2+V-2=0$. You should factorise this and show that $V=1$. Let us look at one more value of $k$ which gives $V$ as a whole number, and after that we will find a general formula for $k$ so that we can get $V$ to be any whole number. Now take $k=12$. This gives $V^2+V-12=0$ and hence $V=3$. Notice that in every case we get the equation $V^2+V-k=0$. However, not every value of $k$
gives $V$ as a whole number; for example $k=1$ leads to the Golden Ratio and $k=3$ does not give a whole number either. What is the value of $V$ when $k=3$? Let us try and see which values of $k$ give $V$ as a whole number. The solution of the quadratic equation $V^2+V-k=0$ is $$V={-1 \pm \sqrt{(1+4k)}\over 2}$$ and this will be a whole number when $1+4k$ is the square of an odd number. In the
cases we have seen already $k=6$ and $1+4k=5^2$, $k=2$ and $1+4k=3^2$, and finally $k=12$ and $1+4k=7^2$. You should now be able to find $k$ so that $1+4k=9^2$ and $V=4$. What value of $k$ gives $V=5$? We began by saying that we shall show that every whole number can be written as a continued fraction of the form given above. This means that given a whole number $N$ there must be some value of
$k$ such $V=N$. So which value of $k$ gives $V=N$? For $V$ to be $N$ we must have $$N={-1 \pm \sqrt{(1+4k)}\over 2}$$ or $$1+4k = (2N+1)^2.$$ This shows again that for $V$ to be a whole number, $1+4k$ must be the square of an odd number. Moreover given any whole number $N$, then by taking $k=N^2+N$ you get a continued fraction with the value $N$. Every number can be written as a continued
fraction and continued fractions are sometimes used to give approximations to irrational numbers. See if you can show that $$1 \qquad + \leftb\qquad {1\over\displaystyle 2\;+\; {\strut 1\over \displaystyle 2\;+\; {\strut 1\over \displaystyle 2\;+\; {\strut 1\over \displaystyle 2\;+\; ... }}}}\rightb= \sqrt{2}.$$ This suggests that a good approximation to $\sqrt 2$ is given by $$1 \qquad +
\leftb\qquad {1\over\displaystyle 2\;+\; {\strut 1\over \displaystyle 2\;+\; {\strut 1\over \displaystyle 2\;+\; {\strut 1\over \displaystyle 2\;+\; {\strut 1\over \displaystyle 2 }}}}}\rightb.$$ Find this as a fraction and check with a calculator to see how close it is to $\sqrt 2$.