Termination criterion for a simple continued fraction (source code)

= Termination criterion for a simple continued fraction

A simple continued fraction terminates exactly when its value is rational. For a reduced rational $p/q$, each reciprocal step is one step of the Euclidean algorithm and replaces the denominator by a strictly smaller nonnegative remainder.