lecture5
lecture5
- Modular arithmetic -
Take a, b ∈ Z and m ∈ N. We say that a is congruent to b modulo m if m|a − b, and write for this
a ≡ b mod m
a and b are congruent modulo m if they give the same remainder after division by m.
With this concept we are basically saying we only care about the remainder after divison by some m, that as
far as this remainder is concerned we consider a and b as equal. For given n, in slightly more posh language
we call this remainder when dividing by m the residue. It is the unique r ∈ {0, 1, ..., m − 1} satisfying
n ≡ r mod m. (Recall the Division Theorem).
Maybe it helps you to think of it more explicitly: We basically remove m, and another m, and another
m, and so on, from whatever number under consideration, until we’re left with the remainder/residue mod-
ulo m. Basically we can remove whatever multiple of m we like. If we have the number 1028 but we’re
working only modulo 7 (say, as in the “weekly” setting) then we can do 1028 − 7 − 7 − · · · − 7 until we
get to any other number we desire, but obviously we might prefer a number in {0, 1, ..., 6}, namely 6 if we
started with 1028. Then we can write 1028 ≡ 6 mod 7. We are basically saying “1028 gives remainder 6
after division by 7”. But we could also have written 1028 ≡ 13 mod 7, or 1028 ≡ 20 mod 7, since these give
the same remainder. We’re saying these numbers are “equal” as far as the remainder after division by 7 is
concerned. Another way to think about it is to take a multiple of 7 close to our original number, so since
1022 is a multiple of 7, we can for example just note that
7|1028 − 6
and write
1028 ≡ 6 mod 7.
In any case, the crucial thing to remember is
Now we’ve discussed the main idea let’s establish how we can perform arithmetic in this new setting. When
we manipulate mathematical expressions in equations, especially when they contain many complicated alge-
braic expressions, we tend not to think about what they mean but rather apply a few rules, using the laws
of algebra mechanically - this is “technical know-how”. We’d like to be able to also manipulate modular
arithmetic equations freely, so let’s discuss how to do that. Of course in both cases it is important that if we
had to we could always stop and describe what all the expressions are.
a ≡ b mod m =⇒ b ≡ a mod m,
a ≡ b mod m and b ≡ c mod m =⇒ a ≡ c mod m,
′ ′
a ≡ b mod m and a ≡ b mod m =⇒ a + a′ ≡ b + b′ mod m
a ≡ b mod m and a′ ≡ b′ mod m =⇒ aa′ ≡ bb′ mod m.
[A note on general abstract maths: The first two statements are kind of obvious, since we described congru-
ences as numbers giving the same remainder, but that was just a description - there’s still the actual definition
to check. And they’re important because we want to be able to manipulate congruences like equations. The
second two statements basically say “we can add and multiply together congruences”. This may look obvious
to you, but it’s a falsely justified expectation if it’s just based on what you expect to be true because of the
symbols we used for congruence. We introduced this concept, and there’s no particular reason why a relation
we introduced should respect addition or multiplication. If we had said, for example, that “a ≡ b mod m
means m|ab”, then the proposition wouldn’t be true:
1
Exercise. Suppose that “a ≡ b mod m means m|ab”. Show that 3 ≡ 2 mod 2 and 2 ≡ 3 mod 2. Now also
show that we can’t add these congruences together, in other words show that 3 + 2 ≡ 2 + 3 mod 2 does not
hold.
That wasn’t an interesting exercise - we just wanted it to really be clear that there was something which
needed to be checked.]
Now let’s give a concrete example of how useful the concept can be in action. Let’s say we want to work out
734 × 926 modulo 7. This is very large multiplication, and the number 734 × 926 will have aroud 5 digits
before we start the reduction modulo 7. But from the modular arithmetic laws we see that we don’t need to
do such large multiplications because, since 728 and 924 are multiples of 7, we have that
In other words 734 × 926 leaves remainder 12, or rather remainder 5, after division by 7, which we worked
out without working out 734 × 926 explicitly. Of course we had to work out multiples of 7 aroud 734 and 926,
but these are three digit numbers, so still somewhat easier than finding a multiple of 7 for the 5 digit product.
So when working in modular arithmetic we can add (and therefore subtract) and multiply integers as we
might have hoped. Let’s now discuss something more fiddly - division.
Suppose ad ≡ bd mod m. Can we “cancel out” d from both sides and conclude that a ≡ b mod m? Consider
an example: we have 5 × 4 ≡ 2 × 4 mod 6 but 5 ̸≡ 2 mod 6, so clearly no - we can’t just assume we can divide
both sides by a common factor. However if we replace the modulus 6 by 3, we see that still 5×4 ≡ 2×4 mod 3
but this time also 5 ≡ 2 mod 3, so in this case dividing by a common factor did work. The point is the
modulus has to be coprime to the divisor. The notion of coprimality pervades number theory, so let’s define
it clearly and then give the result for division in modular arithmetic.
Two integers n, m are coprime if they have no common divisors aside from 1. In other words, their greatest
common divisor is one, or (n, m) = 1. (We discussed the greatest common divisor in Lecture 3).
Dividing mod m. Take a, b, d ∈ Z and m ∈ N. Suppose (d, m) = 1. Then
Proof.
So we can divide through if the divisor and modulus are coprime. This is the important fact about dividing
in modular arithmetic.
So in summary: we can add, subtract, and multiply congruences like we can with normal numbers. And we
can divide if the common factor is coprime to the modulus.
Summary of Lecture 5
• Can cleanly write down and understand what it means for numbers to be congruent.
• Be able to do arithmetic in this modular setting.
• Understand that care is needed when dividing - can only divide a common factor through when coprime
to modulus.