On one day, I read a magazine then I'm so interested in the algorithms, one of my favorites is RATCONVERT, i.e., if you have $\dfrac{142}{727}\cong 0.195323246..$ then how do you find $0.195323246.. \cong\dfrac{142}{727},$ the generalization of this problem here:
Given two natural numbers $K, M.$ Find two numbers $u, v$ so that $0\leq u, v< N, \left | \dfrac{u}{v}- \dfrac{K}{M} \right |\leq \dfrac{1}{M}$ with a natural numbers given $N.$
In 1981 Paul Wang had researched this problem in case $N= \sqrt{\dfrac{M}{2}}.$ With that we can prove that there only one solution exists, that's true, assume that there are two solutions $\left ( u_{1}, v_{1} \right ), \left ( u_{2}, v_{2} \right )$ being right by the above conditions, we observe that: $$\left | \frac{u_{1}}{v_{1}}- \frac{u_{2}}{v_{2}} \right |\leq \left | \frac{u_{1}}{v_{1}}- \frac{K}{M} \right |+ \left | \frac{u_{2}}{v_{2}}- \frac{K}{M} \right |\leq \frac{2}{M}$$ $$\Rightarrow \left | u_{1}v_{2}- u_{2}v_{1} \right |\leq \frac{2v_{1}v_{2}}{M}< \frac{2N^{2}}{M}\leq 1\Rightarrow \frac{u_{1}}{v_{1}}= \frac{u_{2}}{v_{2}}$$ On the other hand, $$\left | \frac{u}{v}- \frac{K}{M} \right |\leq \frac{1}{M}\Rightarrow \left | Mu- Kv \right |\leq v< N$$ then if $\dfrac{u}{v}\cong \dfrac{K}{M},$ there exists an integer $r$ so that $\left | r \right |< N, r\equiv Kv\mod M.$ I generalized it and wrote it as an algorithm so that there must exist two conditions $0\leq \left | r \right |< \sqrt{M/2}> v> 0$ and $r\equiv Kv\mod M$ to find $\left ( v, r \right ),$ that's easier. So how to make it work for finding an approximately fraction $\dfrac{p}{q}$ of irrational number $\sqrt{2}$ so that
$$\left | \frac{p}{q}- \sqrt{2} \right |< 0.001$$
I remember Lagrange states that any positive quadratic surd $\sqrt{a}$ has a regular continued fraction which is periodic after some point. There is a few of relationship between two problems, so I need to your help to complete this. Thanks a real lot !