<s>[INST] When $f(x)=\frac{-b^2m-ba+ax}{-mx-bm-a}$ is an integer $a,b,m,x$ are positive integers.
For which $x>0$ is $f(x)$ an integer?
$$f(x)=\frac{-b^2m-ba+ax}{-mx-bm-a}$$
I been trying to play with it, I changed it to:
$$\frac{b^2m-a\left(b+x\right)}{a+m\left(b+x\right)}$$
And then I been trying to say:
$$a+m\left(b+x\right)| b^2m-a\left(b+x\right) $$
$$a+m\left(b+x\right)| (a+m\left(b+x\right))(b+x)$$
So
$$a+m\left(b+x\right)| b^2m-a\left(b+x\right)+ (a+m\left(b+x\right))(b+x)$$
$$a+m\left(b+x\right)| m\left(\left(b+x\right)^2+b^2\right)$$
But I don't see how it helps, so please help me.
 [/INST] Here is a partial answer: Note that
\begin{eqnarray*}
f(x)&=&\frac{b^2m+ba-ax}{bm+a+mx}=\frac{b^2m+ba+bmx-bmx-ax-mx^2+mx^2}{bm+a+mx}\\
&=&\frac{(b-x)(bm+a+mx)+mx^2}{bm+a+mx}=b-x+\frac{mx^2}{bm+a+mx}.
\end{eqnarray*}
So $f(x)$ is an integer if and only if $\frac{mx^2}{bm+a+mx}$ is. This means there is a positive integer $k$ such that
$$mx^2=k(bm+a+mx)=kbm+ka+kmx.$$
In particular $ka=mc$ for some positive integer $c$, so we get
$$mx^2-kmx-kbm+mc=0\qquad\text{ and hence }\qquad x^2-kx-(kb+c)=0.$$
So by the quadratic formula
$$x=\frac{k}{2}\pm\frac{1}{2}\sqrt{k^2+4kb+4c},$$
is an integer. This is an integer if and only if $k^2+4kb+4c$ is a square. So the question is then:

Given positive integers $b$ and $c$, for which positive integers $k$ is 
  $k^2+4kb+4c$ a square?

</s>