# Does $a \equiv b \pmod n$ mean $n \mid a - b$ or $n \mid b -a$

If I have $a \equiv b \pmod{n}$, it means $n \mid b - a$.

But can you write it as $n \mid a - b$ as well?

-
$a \equiv b \pmod{n} \implies n \mid (a-b) \implies a-b = nk$ for some integer $k$. Can you find an integer $m$ such that $b-a = mn$? – JavaMan Dec 8 '11 at 4:33
Yes, because in $x$ divides $y$ if and only if $\pm x$ divides $\pm y$, and $a-b = -(b-a)$. – Arturo Magidin Dec 8 '11 at 4:33
that would just be -1. but my prof always writes it as b - a – jake Dec 8 '11 at 4:34

HINT $\rm\quad n\ |\ c \iff\ \dfrac{c}{n}\in \mathbb Z \iff -\dfrac{c}{n}\: =\: \dfrac{-c}{n} \in \mathbb Z\ \iff\ n\ |\: -c\:.\$ Now let $\rm\ c = a-b\:.$

I.e. $\ \mathbb Z$ closed under negation $\rm\: \Rightarrow\ n\: \mathbb Z\:$ closed under negation, i.e. $\rm\: -(n\: \mathbb Z)\ =\ (-n)\ \mathbb Z$

-

It can be written both ways. $$n\mid a-b \iff kn = a-b \iff k'n = b-a \iff n\mid b-a$$ for some $k\in \mathbb{Z}$ where $k' = -k$. It's just a way of stating that if $n\mid m$ then $n\mid (-m)$.

-

Yes: $n\mid b-a$ means that there is an integer $k$ such that $b-a = kn$, and $n\mid a-b$ means that there is an integer $\ell$ such that $a-b=\ell n$. Since $a-b=-(b-a)$, these are two ways of saying the same thing: $$b-a = kn\iff a-b=-(b-a)=(-k)n\;.$$

-