Find bounded integers $x, y$ minimizing $| t - x * y |$

48 Views Asked by At

How do I find the integers $x$ and $y$ minimizing $| t - x \cdot y |$ with $1 \leq x < N$ and $1 \leq y < M$ ?

Background: A clock signal is divided by two hardware prescalers (with a limited number of bits), how do I produce an output frequency that is as close as possible to the desired frequency ?