TITLE: Congruent Modulo $n$: definition
QUESTION [12 upvotes]: In an Introduction to Abstract Algebra by Thomas Whitelaw, he gives examples of the congruence mod operation, such as $13 \equiv5 \pmod4$,  and $9 \equiv -1 \pmod 5$. But when I first learned about the modulo operation my junior year, I would have told you that $13 \equiv 1 \pmod 4$, and that $9 \equiv 4 \pmod 5$.

Is this just a difference in the definition of modulo? Or is this pretty typical (to not take it to the largest factor, or one over)?

REPLY [11 votes]: Congruence, as described in your algebra book, is a relation. We have $a\equiv b\pmod{m}$ precisely if $m$ divides $a-b$. Thus the following are all true: $17\equiv 2\pmod{5}$, $17\equiv 7\pmod{5}$, $17\equiv -13\pmod{5}$, and so on.
You met the modulo operator, or operation, in your third year, probably in a Computer Science course.  There, some people write $a\bmod m$ for the remainder when $a$ is divided by $m$. Thus $a\bmod m$ is an object, a number. So $a\bmod m=b$ means that $b$ is the remainder when $a$ is divided by $m$.
To make things more confusing, sometimes they write $a\bmod m\equiv b$ to mean the same thing. 
Thus $17\bmod 5=2$ is true, while $17\bmod 5=12$ is false, since $12$ is not the remainder when $17$ is divided by $5$. 
Remark: The congruence notation of your algebra book goes back to Gauss. For about $150$ years, congruence modulo $m$ was a relation, and it still is in almost all of mathematics.
It would have been nice, when Computer Science people were looking for a notation for the remainder, if they had chosen a notation that was not so close to standard notation for something else. And what's worse, the "something else" is related, guaranteeing decades of student confusion. Luckily, in most computer languages, "mod" is not used for the remainder operator.  
That was a little harsh. So in a spirit of cooperation, I will use both notions in a single sentence. If $m$ is a positive integer, then
$$a\equiv b\pmod{m} \quad\text{if and only if}\quad a\bmod m=b\bmod m.$$