<s>[INST] Properties of Continued fractions of $\sqrt n$ I got to know from this Brilliant article (no pun intended) that the continued fraction expansion expression of $\sqrt n$ is of the form $[a_0,\overline{a_1,a_2,\dots ,a_k}]$ for integers $a_i$ where

*

*$a_0=\lfloor\sqrt n\rfloor$ and $a_k=2a_0$

*$a_1,a_2\dots ,a_{k-1}$ is a palindrome, i.e., $a_i=a_{k-i}$
Unfortunately, these properties were presented without proof, and a quick google search didn't yield much. A suggested question seems to be similar to a part of my question, although the answers seem to use too advanced machineries for me to understand.
I would like to have simple proofs or intuitive explanations to understand why these beautiful patters hold. This table listing some continued fractions may be helpful. This paper suggested by mathcounterexamples.net is quite informative.
 [/INST] here I give an example fo converting the square root to continuous fraction:
We want to find $\sqrt{41}$. The greatest perfect square less than $41$ is $36=6^2$ , so we may write:
$\sqrt{41}\approx 6 +\frac 1 x$
We have:
$\frac 1 x=\sqrt {41}-6\Rightarrow x=\frac 1{\sqrt{41}-6}\space\space\space\space(1)$
Multiplying numerator and denominator be conjugate $\sqrt {41}+6$ we get:
$x=\frac {\sqrt{41}+6} 5$
$\sqrt{41}+6>10 \Rightarrow x>2$
So we may write:
$x=2+\frac 1y=\frac{\sqrt{41}+6}5\Rightarrow \frac 1y=\frac{\sqrt{41}-4}5\Rightarrow y=\frac 5{\sqrt{41}-4}$
Multiplying numerator and denominator be conjugate $\sqrt {41}+4$ we get:
$y=\frac {\sqrt{41}+4}5>2$
Suppose:
$\frac 1y=2+\frac1z$
We have:
$\frac 1z=\frac{\sqrt{41}+4}5-2=\frac{\sqrt{41}-6}5$
$\Rightarrow z=\frac 5{\sqrt{41}-6}$
Multiplying numerator and denominator be conjugate $\sqrt {41}+6$ we get:
$z=\sqrt {41}+6>12$
Let $z=12+\frac 1u$, we can write:
$\frac 1 u=\sqrt {41}+6-12=\sqrt{41}-6\space\space\space\space(2)$
Comparing relation (2) with (1) we find that $u=x$, s0 our continuous fraction is:
$$\sqrt {41}\approx 6+\frac1 {2+\frac1{2+\frac1{12+\frac 1{2+\frac1{...}}}}}$$
Or $\sqrt {41}\approx(6, 2, 2 ,12, 2, 2, 12, ...)$
Now we convert one part of this to ordinary fraction:
$2+\frac 1{12}=\frac {25}{12}: \frac 1{\frac{25}{12}}=\frac {12}{25} $
$2+\frac{12}{25}=\frac{62}{25}: \frac 1{\frac{62}{25}}=\frac {25}{62}$
finally :
$\sqrt{41}\approx [6+\frac{25}{62}=\frac{397}{62}]\approx 6.403$
</s>