# Solving an equation involving the ceiling function

I am trying to solve the following equation for $m$ in terms of $k$ and $n$:

$k + m = \left\lceil{\frac{n + m}{4}}\right\rceil$

($n$ and $k$ are integers, and $m$ must be one too)

Seems like it should be simple but I can't figure it out...

What is the general approach for solving equations like this?

-

$$k+m=(n+m)/4+q(m,n)$$ where $q(m,n)$ is $0$, $1/4$, $1/2$, or $3/4$. $$4k+4m=n+m+4q(m,n),\quad3m=n-4k+4q(m,n),\quad m=(n-4k)/3+r(m,n)$$ where $r(m,n)=(4/3)q(m,n)$ is $0$, $1/3$, $2/3$, or $1$. So we get $$m=\lceil(n-4k)/3\rceil$$ except in the case where $q(m,n)=3/4$, in which case $m=1+((n-4k)/3)$.
Start with any old $m$, say, $m=0$. If $k=\lceil n/4\rceil$, you're done. If $k\lt\lceil n/4\rceil$, then add $1$ to $m$, over and over again. Each time, the left side goes up by $1$, while the right side either goes up by $1$ (one-quarter of the time) or doesn't change (three-quarters of the time). So eventually the left side will exactly equal the right side, and there's your value of $m$.
If $k\gt\lceil n/4\rceil$, then repeatedly subtract $1$ from $m$, and argue the same way.