Lecture 13

Definition: We say that aa is congruent to bb modulo mm if m(ab)m\mid(a-b). Often we abbreviate, and say congruent mod mm.

We use the notation ab(modm)a\equiv b\pmod{m} to indicate that aa and bb are congruent modulo mm.

For example, 3167267(mod100);3167\equiv 267\pmod{100}; indeed, the fact that these two positive integers have the same last two digits means that their difference is a multiple of 100100.

We can now say that an even number is a number congruent to 00 (modulo 22), and an odd number is a number congruent to 11 (modulo 22).

Rather than saying that “nn is of the form 18k44018k-440”, we can say that “nn is congruent to 440-440, modulo 1818”.

Arguments about time frequently involve understandings of congruences. For example, I was born on a Sunday, and the closing ceremony of the 2012 Summer Olympics took place on a Sunday too. So the number of days since the former is congruent to the number of days since the latter, modulo 77.

Notice that saying that aa is congruent to 00, modulo mm, is exactly the same as saying that aa is a multiple of mm (since it’s saying that m(a0)m\mid(a-0)).

As we’ve defined it, a congruence modulo mm doesn’t say that two things are equal, just that their difference is a multiple of mm.

But it does behave suspiciously like an equality, as we’re about to see.


Here are some properties of congruences, true for all integers:

  1. We always have aa(modm)a\equiv a\pmod{m};

  2. If ab(modm)a\equiv b\pmod{m}, then ba(modm)b\equiv a\pmod{m};

  3. If ab(modm)a\equiv b\pmod{m} and bc(modm)b\equiv c\pmod{m}, then ac(modm)a\equiv c\pmod{m};

  4. If ab(modm)a\equiv b\pmod{m} and cd(modm)c\equiv d\pmod{m}, then a+cb+d(modm)a+c\equiv b+d\pmod{m};

  5. If ab(modm)a\equiv b\pmod{m} and cd(modm)c\equiv d\pmod{m}, then acbd(modm)a-c\equiv b-d\pmod{m};

  6. If ab(modm)a\equiv b\pmod{m} and cd(modm)c\equiv d\pmod{m}, then acbd(modm)ac\equiv bd\pmod{m}.


For (a):

Since aa=0a-a=0, we have m(aa)m\mid(a-a).

For (b):

If ab(modm)a\equiv b\pmod{m}, we have m(ab)m\mid (a-b). But then m(ab)m\mid-(a-b), which says m(ba)m\mid(b-a), or in other words ba(modm)b\equiv a\pmod{m}.

For (c):

As ab(modm)a\equiv b\pmod{m}, we have m(ab)m\mid (a-b); similarly as bc(modm)b\equiv c\pmod{m}, we have m(bc)m\mid(b-c). But then m((ab)+(bc))=(ac),m\mid((a-b)+(b-c))=(a-c), which says that ac(modm)a\equiv c\pmod{m}.

For (d):

As ab(modm)a\equiv b\pmod{m}, we can write ab=kma-b=km for some integer kk; similarly, as cd(modm)c\equiv d\pmod{m}, we can write cd=lmc-d=lm for some integer ll.

As a result, (a+c)(b+d)=(ab)+(cd)=km+lm=(k+l)m,(a+c)-(b+d) = (a-b)+(c-d) = km + lm = (k+l)m, so m((a+c)(b+d))m\mid\left((a+c)-(b+d)\right), so a+cb+d(modm)a+c\equiv b+d\pmod{m}.

For (e):

As above, we can write ab=kma-b=km, and cd=lmc-d=lm. Then (ac)(bd)=(ab)(cd)=kmlm=(kl)m,(a-c)-(b-d) = (a-b)-(c-d) = km - lm = (k-l)m, so m((ac)(bd))m\mid((a-c)-(b-d)), so acbd(modm)a-c\equiv b-d\pmod{m}.

For (f):

As ab(modm)a\equiv b\pmod{m}, then we can write a=b+kma = b+km for some integer kk (since aba-b is a multiple of mm). Similarly, as cd(modm)c\equiv d\pmod{m} we can write c=d+lmc = d+lm.

But then ac=(b+km)(d+lm)=bd+(bl+dk+klm)mac = (b+km)(d+lm) = bd + (bl+dk+klm)m, which says that acbd(modm)ac\equiv bd\pmod{m}.

I interpret all that as saying that, provided you’re careful and justify any unusual steps, the language of congruences behaves somewhat like equality. (In particular, our choice of notation, looking a bit like an overenthusiastic equals sign, wasn’t a bad choice). This philosophy will get heavy use from now on!

Back at school, you probably learned facts like “an odd number times an even number is an even number”. We can now give an systematic explanation of facts like these, using modular arithmetic.

If aa is odd and bb is even then a1(mod2)b0(mod2)\begin{aligned} a &\equiv 1 \pmod{2}\\ b &\equiv 0 \pmod{2}\\\end{aligned} and then (because we can multiply congruences) ab1×0=0(mod2),ab \equiv 1\times 0 = 0\pmod{2}, which says that abab is even.

Since we can add congruences, we can give similar explanations of addition facts (like “an odd number plus an even number is an odd number”).

The language of congruences gives us ways of writing down similar facts about other moduli.

For example, if a3(mod7)a\equiv 3\pmod{7}, and b4(mod7)b\equiv 4\pmod{7}, then ab125(mod7)ab\equiv 12{}\equiv 5\pmod{7}.

We can use these ideas to make multiplication tables of congruences. For example, here’s a multiplication table modulo 55:

×\times 0 1 2 3 4
0 0 0 0 0 0
1 0 1 2 3 4
2 0 2 4 1 3
3 0 3 1 4 2
4 0 4 3 2 1

So, for example, this tells us that 2×43(mod5)2\times 4\equiv 3\pmod{5}.

Notice that this shares some features with a usual multiplication table. For example, there is a column and a row of zeroes, because if you multiply something by something congruent to zero mod 55, you get something congruent to zero mod 55. Also, multiplying by 11 doesn’t change anything.

Why do we only need to consider rows and columns numbered from 00 to 44? This is a consequence of division with remainder.


Let aa and bb be integers, with b>0b>0. Then aa is congruent (modulo bb) to a unique integer in the set {0,1,,b1}.\{0,1,\ldots,b-1\}.


We’ll show that such a number exists, first, and then we’ll show that it’s unique.

By division with remainder, we can write a=qb+ra=qb+r for some integer qq and some integer rr with 0r<b0\leq r<b. But then that says that ar=qba-r=qb, and hence ar(modb)a\equiv r\pmod{b}. That shows that aa is congruent to some number in that set.

Now, we’ll prove uniqueness. In fact we never proved that division with a unique remainder was possible, so let’s mend that now.

Suppose that ar1(modb)a\equiv r_1\pmod{b} and also ar2(modb)a\equiv r_2\pmod{b}. Then 0=aar2r1(modb)0=a-a\equiv r_2-r_1\pmod{b} by subtracting, so b(r2r1)b\mid(r_2-r_1).

But since 0r1<b0\leq r_1<b and 0r2<b0\leq r_2<b, we have b=0b<r2r1<b0=b.-b = 0-b < r_2-r_1 < b-0 = b. So r2r1r_2-r_1 is a multiple of bb strictly between b-b and bb: it must be zero, so r1=r2r_1=r_2, which proves uniqueness.

This proposition has a lot of consequences.

It means we can divide up the integers into sets, called congruence classes or residue classes, based on which number from {0,,b1}\{0,\ldots,b-1\} they’re congruent to. So, for b=5b=5, we divide the integers into: