The CF of p/q is the list of Euclidean quotients [a0; a1, a2, ...]; its convergents pk/qk = akpk-1+pk-2 over akqk-1+qk-2 close in on the target, alternating above and below.
| p | = | a·q | + r | quotient a |
|---|
p_k q_{k-1} - p_{k-1} q_k = (-1)^{k-1} and the error bound |x - p_k/q_k| < 1/q_k².
See junior.md for the worked example and professional.md for the proofs.