[Math] Using inverses to solve congruences

discrete mathematics

The example I am looking at is for the question "what are the solutions of the linear congruence 3x ≡ 4 (mod7) ?

Let's say we know -2 is an inverse of 3mod7.

So we multiply by it: -2 * 3x ≡ -2*4 (mod 7)

*The book then says the answer is x ≡ -8 ≡ 6 (mod 7)

Why? I don't understand why 6 is positive.

Best Answer

In congruence $\pmod m$, two integers $a,b$ are equivalent if $m$ divides $(a-b)$

Here $x\equiv-8\pmod7\equiv6$ as $7$ divides $6-(-8)=14$

$x\equiv-8\pmod7\implies x=7m-8$ where $m$ is any integer

We can safely write $x\equiv7m_1-8\pmod7$ where $m_1$ is any integer

But it is often customary to keep the Right hand side in $[0,m-1]$ or $(-\frac m2,\frac m2]$ for $\pmod m$