Formula to Find $k$ to put $\frac nm$ in between a Range

29 Views Asked by At

I have a function $$f(n,m)=-\frac {2n}m+1+2k$$ where $n$ and $m$ are both positive integers. Is there a way to find the positive integer value $k$ that would put $-1 \leq f(n,m) \leq 1$ for an $n$ and $m$ (without using $\mathbb{floor}$, $\mathbb{ceil}$, or $\mathbb{mod}$)?