Continued-fraction tail formula (source code)

= Continued-fraction tail formula

If $p_n/q_n=[a_0,\ldots,a_n]$, then appending a positive tail $x$ gives
$$
[a_0,\ldots,a_n,x]
=\frac{p_nx+p_{n-1}}{q_nx+q_{n-1}}.
$$