Combining the effects of two moduli If I have:

$((x \bmod m_1) \bmod m_2) = z$

With $x,m_1,m_2$ given positive integers, is there some $y$ such that

$x \bmod y = z$
$x\geq z$.

If $x=z$, then $m_1,m_2&gt;z$, so you can take $y=m_1$.

If $x&gt;z$, then you can take $y=x-z$.
$x\geq z$.

If $x=z$, then $m_1,m_2&gt;z$, so you can take $y=m_1$.

If $x&gt;z$, then you can take $y=x-z$.