The proof proceeds by strong induction. For all $r \in \Z_{\ge 0}$, let $P \left({r}\right)$ be the proposition: :$a_r = \left\lfloor{\dfrac{\left\lfloor{\sqrt n}\right\rfloor + P_r} {Q_r} }\right\rfloor$ where: :$P_r = \begin{cases} 0 & : r = 0 \\ a_{r - 1} Q_{r - 1} - P_{r - 1} & : r > 0 \\ \end{cases}$ :$Q_r = \begin{cases} 1 & : r = 0 \\ \dfrac {n - {P_r}^2} {Q_{r - 1} } & : r > 0 \\ \end{cases}$ === Edge Cases === By definition of the structure of a continued fraction: :$\sqrt n = a_0 + \dfrac 1 {x_1}$ for some $a_0 \in \Z$ and $x_1 \in \R_{>0}$. Thus: {{begin-eqn}} {{eqn | l = a_0       | r = \left\lfloor{\sqrt n}\right\rfloor       | c = {{Defof|Floor Function}} }} {{eqn | r = \left\lfloor{\dfrac {\sqrt n + 0} 1}\right\rfloor       | c =  }} {{eqn | r = \left\lfloor{\dfrac {\sqrt n + P_0} {Q_0} }\right\rfloor       | c = Definition of $P_0$ and $Q_0$ }} {{eqn | r = \left\lfloor{\dfrac {\left\lfloor{\sqrt n}\right\rfloor + P_0} {Q_0} }\right\rfloor       | c = Floor of $\dfrac {x + m} n$ }} {{end-eqn}} Thus $P \left({0}\right)$ is seen to hold. We have that: :$\sqrt n = a_0 + \dfrac 1 {x_1}$ Then: {{begin-eqn}} {{eqn | l = \dfrac 1 {x_1}       | r = \sqrt n - a_0       | c =  }} {{eqn | ll= \leadsto       | l = x_1       | r = \dfrac 1 {n - a_0}       | c =  }} {{eqn | r = \dfrac {\sqrt n + a_0} {\left({\sqrt n - a_0}\right) \left({\sqrt n + a_0}\right)}       | c = multiplying top and bottom by $\sqrt n + a_0$ }} {{eqn | r = \dfrac {\sqrt n + P_1} {Q_1}       | c = Definition of $P_1$ and $Q_1$ }} {{end-eqn}} By definition of the structure of a continued fraction: :$x_1 = a_1 + \dfrac 1 {x_2}$ for some $a_1 \in \Z$ and $x_2 \in \R_{>0}$. Hence: {{begin-eqn}} {{eqn | l = a_1       | r = \left\lfloor{\dfrac {\sqrt n + P_1} {Q_1} }\right\rfloor       | c = {{Defof|Floor Function}} }} {{eqn | r = \left\lfloor{\dfrac {\left\lfloor{\sqrt n}\right\rfloor + P_1} {Q_1} }\right\rfloor       | c = Floor of $\dfrac {x + m} n$ }} {{end-eqn}} Thus $P \left({1}\right)$ is seen to hold. === Basis for the Induction === We have that: :$x_1 = a_1 + \dfrac 1 {x_2}$ Then: {{begin-eqn}} {{eqn | l = \dfrac 1 {x_2}       | r = x_1 - a_1       | c =  }} {{eqn | r = \dfrac {\sqrt n + P_1} {Q_1} - a_1       | c =  }} {{eqn | r = \dfrac {\sqrt n + P_1 - a_1 Q_1} {Q_1}       | c =  }} {{eqn | ll= \leadsto       | l = x_2       | r = \dfrac {Q_1} {\sqrt n - \left({a_1 Q_1 - P_1}\right) }       | c =  }} {{eqn | r = \dfrac {Q_1} {\sqrt n - P_2}       | c = Definition of $P_2$ }} {{eqn | r = \dfrac {Q_1 \left({\sqrt n + P_2}\right)} {\left({\sqrt n - P_2}\right) \left({\sqrt n + P_2}\right)}       | c = multiplying top and bottom by $\sqrt n + P_2$ }} {{eqn | r = \dfrac {Q_1 \left({\sqrt n + P_2}\right)} {n - {P_2}^2}       | c = Difference of Two Squares }} {{eqn | r = \dfrac {\sqrt n + P_2} {\left({n - {P_2}^2}\right) / Q_1}       | c = By Expansion of Associated Reduced Quadratic Irrational, $\left({n - {P_2}^2}\right) / Q_1$ is an integer }} {{eqn | r = \dfrac {\sqrt n + P_2} {Q_2}       | c = Definition of $Q_2$ }} {{end-eqn}} By definition of the structure of a continued fraction: :$x_2 = a_2 + \dfrac 1 {x_3}$ for some $a_2 \in \Z$ and $x_3 \in \R_{>0}$. Thus: {{begin-eqn}} {{eqn | l = a_2       | r = \left\lfloor{\dfrac {\sqrt n + P_2} {Q_2} }\right\rfloor       | c = {{Defof|Floor Function}} }} {{eqn | r = \left\lfloor{\dfrac {\left\lfloor{\sqrt n}\right\rfloor + P_2} {Q_2} }\right\rfloor       | c = Floor of $\dfrac {x + m} n$ }} {{end-eqn}} This is the basis for the induction. === Induction Hypothesis === Now it needs to be shown that, if $P \left({k - 1}\right)$ and $P \left({k}\right)$ ares true, for all $k \ge 2$, then it logically follows that $P \left({k + 1}\right)$ is true. This is the induction hypothesis: :$a_k = \left\lfloor{\dfrac{a_0 + P_k} {Q_k} }\right\rfloor$ where: :$P_k = a_{k - 1} Q_{k - 1} - P_{k - 1}$ :$Q_k = \dfrac {n - {P_k}^2} {Q_{k - 1} }$ and: :$x_k = \dfrac{\sqrt n + P_k} {Q_k}$ from which it is to be shown that: :$a_{k + 1} = \left\lfloor{\dfrac{a_0 + P_{k + 1} } {Q_{k + 1} } }\right\rfloor$ where: :$P_{k + 1} = a_k Q_k - P_k$ :$Q_{k + 1} = \dfrac {n - {P_{k + 1} }^2} {Q_k}$ and: :$x_{k + 1} = \dfrac{\sqrt n + P_{k + 1} } {Q_{k + 1} }$ === Induction Step === This is the induction step: By definition of the structure of a continued fraction: :$x_k = a_k + \dfrac 1 {x_{k+1} }$ where: :$x_{k+1} \in \R_{>0}$ :$a_k = \left\lfloor{\dfrac{a_0 + P_k} {Q_k} }\right\rfloor$ by the induction hypothesis. Then: {{begin-eqn}} {{eqn | l = \dfrac 1 {x_{k+1} }       | r = x_k - a_k       | c =  }} {{eqn | r = \dfrac {\sqrt n + P_k} {Q_k} - a_k       | c =  }} {{eqn | r = \dfrac {\sqrt n + P_k - a_k Q_k} {Q_k}       | c =  }} {{eqn | ll= \leadsto       | l = x_2       | r = \dfrac {Q_k} {\sqrt n - \left({a_k Q_k - P_k}\right) }       | c =  }} {{eqn | r = \dfrac {Q_k} {\sqrt n - P_{k + 1} }       | c = Definition of $P_{k + 1}$ }} {{eqn | r = \dfrac {Q_k \left({\sqrt n + P_{k + 1} }\right)} {\left({\sqrt n - P_{k + 1} }\right) \left({\sqrt n + P_{k + 1} }\right)}       | c = multiplying top and bottom by $\sqrt n + P_{k + 1}$ }} {{eqn | r = \dfrac {Q_k \left({\sqrt n + P_{k + 1} }\right)} {n - {P_{k + 1} }^2}       | c = Difference of Two Squares }} {{eqn | r = \dfrac {\sqrt n + P_{k + 1} } {\left({n - {P_{k + 1} }^2}\right) / Q_k}       | c = By Expansion of Associated Reduced Quadratic Irrational, $\left({n - {P_{k + 1} }^2}\right) / Q_k$ is an integer }} {{eqn | r = \dfrac {\sqrt n + P_{k + 1} } {Q_{k + 1} }       | c = Definition of $Q_{k + 1}$ }} {{end-eqn}} By definition of the structure of a continued fraction: :$x_{k + 1} = a_{k + 1} + \dfrac 1 {x_{k + 2} }$ for some $a_{k + 1} \in \Z$ and $x_{k + 2} \in \R_{>0}$. Thus: {{begin-eqn}} {{eqn | l = a_{k + 1}       | r = \left\lfloor{\dfrac {\sqrt n + P_{k + 1} } {Q_{k + 1} } }\right\rfloor       | c = {{Defof|Floor Function}} }} {{eqn | r = \left\lfloor{\dfrac {\left\lfloor{\sqrt n}\right\rfloor + P_{k + 1} } {Q_{k + 1} } }\right\rfloor       | c = Floor of $\dfrac {x + m} n$ }} {{end-eqn}} So $P \left({k}\right) \implies P \left({k + 1}\right)$ and the result follows by the Second Principle of Mathematical Induction. Hence the result. {{qed}}