How does one prove that the continued fraction representations of rational numbers are finite?
For every $x\in\mathbb{R}$, the (simple) continued fraction representation of $x$ is: $$ x = [a_0; a_1, a_2, ...] = a_0 + \frac{1}{a_1 + \frac{1}{a_2 + \frac{1}{...}}} $$ where $a_0\in\mathbb{Z}$ and $a_k\in\mathbb{N}$ for $k\geq 1$, which are themselves obtained as follows: $$ \begin{align} r_0 &= x \\ \forall k \geq 0,\quad a_k &= \lfloor r_k \rfloor \\ \forall k \geq 0,\quad r_{k+1} &= \begin{cases} 1 / (r_k-a_k) & \text{if } r_k > a_k \\ 0 & \text{otherwise} \end{cases} \end{align} $$ and if there exists $n$ for which $r_n > r_{n+1} = 0$, then we correct $a_n\mapsto a_n-1$.
Clearly if the sequence $a_k$ converges to 0, then $x$ is rational. But the converse does not seem trivial at all; why does this recursion necessarily terminate if $x = p/q$? Contraposition does not seem evident to me here either. Is there another way to think about this?