\(\displaystyle{a}\equiv{24}{\left({b}\text{mod}{31}\right)}\)
We can find a such that
\(\displaystyle-{15}\leq{a}\leq{15}\)
by consecutively substracting 31 from 24 until we obtain a value between -15 and 15.
\(\displaystyle{a}\equiv{24}{\left({b}\text{mod}{31}\right)}\)

\(\displaystyle\equiv{24}-{31}{\left({b}\text{mod}{31}\right)}\)

\(\displaystyle\equiv-{7}{\left({b}\text{mod}{31}\right)}\) SInce -7 is between -15 and 15: \(\displaystyle{a}=-{7}\)

\(\displaystyle\equiv{24}-{31}{\left({b}\text{mod}{31}\right)}\)

\(\displaystyle\equiv-{7}{\left({b}\text{mod}{31}\right)}\) SInce -7 is between -15 and 15: \(\displaystyle{a}=-{7}\)