Let $a,b,n \in \mathbb Z$. Find the smallest value of $n$ such that $b\mod n = a$ where $a,b$ are known values and $b > a$.
What's the most efficient way to solve such a problem? The naive approach would be choose values of $n$ and increment up until the smallest $n$ is found.