Let $k$, $p$ and $r$ be constant values
Find the $x$ with the smallest absolute value so that $ \frac{k - r - x}{p + r + x}\in\mathbb{Z} $
Let $k$, $p$ and $r$ be constant values
Find the $x$ with the smallest absolute value so that $ \frac{k - r - x}{p + r + x}\in\mathbb{Z} $
Hint: To look for integer solutions of $ \frac{a-x}{b+x}=c\tag{1} $ it might be useful to look at the factorizations of $a+b$ since $ a+b=(b+x)(c+1)\tag{2} $ Example: $k=100,p=10,r=5\Rightarrow a=k-r=95,b=p+r=15$.
$a+b=110=2\cdot5\cdot11$: to find the absolutely smallest $x$ (which I assume means the smallest in absolute value), find the factor of $a+b=110$ closest to $b=15$. That would be $11$. So let $(b+x)=11$ and $(c+1)=10$. This yields $x=-4$ to be the absolutely smallest $x$: $ \frac{100-5+4}{10+5-4}=\frac{99}{11}=9 $ Extension: due to explanation by Graymat.
Graymat has clarified that the question is to find the smallest $x$ so that $(1)$ is satisfied for $c\in\mathbb{Z}$. Consdiering $(2)$, we would be looking for the $x$ closest to $0$ so that $ \frac{a+b}{b+x}\in\mathbb{Z}\tag{3} $ To find this $x$, let $ c=\left\lfloor\frac{a+b}{b}\right\rfloor\tag{4} $ The $x$ we are looking for would be the absolutely smaller of $ \frac{a+b}{c}-b\qquad\text{and}\qquad\frac{a+b}{c+1}-b\tag{5} $ Application to previous example:
Computing $c=\left\lfloor\frac{110}{15}\right\rfloor=7$, $x$ is the absolutely smaller of $\frac{110}{7}-15=\frac57$ and $\frac{110}{8}-15=-\frac54$. Therefore, $x=\frac57$, and $ \frac{95-\frac57}{15+\frac57}=6 $