Suppose we have a positive rational number $a/b$ in lowest terms. We can write it as a continued fraction
$$[a_0;a_1,a_2,\ldots, a_n]=a_0+\cfrac{1}{a_1+\cfrac{1}{a_2+\ddots}}.$$
If $a/b\neq 1$, then we there is a unique expansion subject to the condition that $a_n\geq 2$.
There is a simple algorithm (essentially the Euclidean algorithm) to determine the $a_i$. However, I am curious to know if there is a good way to determine if $a_n=2$ (or more generally, to determine $a_n$) WITHOUT doing that long computation, i.e., something that sheds no light on the values of any of the other $a_k$, or even what $n$ is. Is there a nice characterization/recognition principle for the set of all positive rational numbers whose continued fraction expansion ends with $2$?
As an example of something that almost but doesn't quite work, assume we were given a solution to $ax=by\pm 1$ with $0\leq x\leq b/2$ (which I don't know how to compute without the Euclidean algorithm, but which, for the sake of argument, we can assume we are given). Then I think we have something like $a_n=\lfloor b/x \rfloor$. However, I know of no way to estimate the size of the minimal positive representative of $\pm a^{-1}\pmod b$ without computing it exactly.