Solving a system of modular equations

modular arithmetic

I am trying to solve this system of equations:

$24x ≡ 12 \hspace{5pt} (\mathrm{mod} \hspace{2pt} 63)$

$x ≡ 2\hspace{5pt} (\mathrm{mod} \hspace{2pt} 27)$

So I know that the second equation is equivalent to $x=27y+2$, but when I plug it into $24x ≡ 12\hspace{5pt} (\mathrm{mod} \hspace{2pt} 63)$, I got $2y ≡ 3\hspace{5pt} (\mathrm{mod} \hspace{2pt} 7)$ and I don’t know what to do next… Did I do something wrong?

Best Answer

$\!\!\bmod 7\!:\,\ 2y\equiv 3\equiv 10\iff y\equiv 5\iff y = 5\!+\!7n,\,$ hence

$x = 2\! +\! 27y = 2\!+\!27(5\!+\!7n) =\, \bbox[5px,border:1px solid #c00]{137+ 189n}\ $ is our solution.

Remark $\ $ For completeness below are the steps you omitted

$\!\!\bmod 27\!:\,\ x\equiv 2\iff x = 2\!+\!27y,\ y\in \Bbb Z\ $ so $\!\!\bmod 63:\,\ 24x = 24(2\!+\!27y) \equiv 12 \iff 18y \equiv 27\!\!\overset{\ \large \div 9}\iff \bmod 7\!:\,\ 2y \equiv 3$


It's trivial to compute $\,a/2\bmod m$ odd since $\,2\mid a\,$ or $\,2\mid a\color{#c00}{\!+\!m},\,$ being opposite parity, so choosing the rep $\,a\equiv a\!+\!m\,$ that is even makes the quotient exact, e.g. $\bmod 7\!:\,\ y\equiv 3/2 \equiv (3\!\color{#c00}{+\!7})/2\equiv 5$

More generally modular inverses and fractions can be easily algorithmically computed by the (fractional) extended Euclidean algorithm, or Gauss's algorithm, or inverse reciprocity, etc.