Modular Arithmetic: The Beginning: 1 Divisibility
Modular Arithmetic: The Beginning: 1 Divisibility
1 Divisibility
We call an integer a a multiple of another integer m, if m completely divides
a - that is, upon dividing a by m we get 0 as our remainder. For brevity, this
statement ”a is a multiple of m” or ”m divides a” is denoted as m|a.
For example, 12 is a multiple of 4 - this is denoted by 4|12. Similarly one can
state that 6|36 or 2|2n for all integral values of n. However, stating 5|12 would
be wrong, as 12 is not a multiple of 5.
The above notation can also be rephrased as below:
1. m|ka when k ∈ Z
2. m|a + b, m|a − b
3. m|ka ± lb when k, l ∈ Z
4. If m|a + c for some c ∈ Z, then m|c
1
3. This one just a combined result of (1) and (2).
4. m|a + c and m|a. Now applying the second part of property (2), m|(a +
c) − a ⇒ m|c.
The proof of the fifth property needs a little bit of calculation, which we show
below:
(a − b)(c − d)
= ac − ad − bc + bd
= ac − bd + 2bd − ad − bc
= ac − bd + bd − ad + bd − bc
= ac − bd − d(a − b) − b(c − d)
⇒ ac − bd = (a − b)(c − d) + d(a − b) + b(c − d)
The right hand side is a multiple of m, and so the left hand side must also
be divided by m.
1.2 Exercises
This section will contain some really easy exercises. They can make you feel
to ignore them - however, working them out will be quite helpful for our next
steps.
1. The sum of two prime numbers is 999. What are the numbers?
2. p2 + p has two prime divisors. Find out all the possible values of p.
3. (Division Algorithm) Prove that for any two integers a and b (b 6= 0),
there exist unique integers q and r such that a = bq + r and 0 ≤ r < b.
2 Congruence
Congruence is the backbone of modular arithmetic. Let a, b, and m be integers,
with m 6= 0. We say that a and b are congruent modulo m if a and b have the
same remainders when they are divided by m. For example, let m=13, a=43
and b=17. Here 43 and 17 have the same remainder 4 when they are divided
by 13. There is a good way to represent this.
43 ≡ 17(mod 13)
Again, note that 43 ≡ 4(mod 13) is also true. Because 4 gives remainder 4
when divided by 13. Now we’ll look at some basic properties of congruence:
2
2.1 Basic Properties of Congruence
1. If a ≡ b(mod m) then m divides a − b. In other words, if a ≡ 0(mod m)
then m|a.
2. a ≡ a(mod m) (reflexivity).
3. a ≡ b(mod m) and b ≡ c(mod m), then a ≡ c(mod m) (transitivity).
4. If a ≡ b(mod m), then b ≡ a(mod m).
5. a ≡ b(mod m) and c ≡ d(mod m), then a + c ≡ b + d(mod m) and a − c ≡
b − d(mod m).
6. If a ≡ b(mod m), then for any integer k, ka ≡ kb(mod m).
7. If ka ≡ kb(mod m) for any integer k which is co-prime to m, then a ≡
b(mod m)
8. If a ≡ b(mod m) and c ≡ d(mod m), then ac ≡ bd(mod m). In general, if
ai ≡ bi (mod m), i = 1, ..., k, then a1 ...ak ≡ b1 ...bk (mod m). In particular,
if a ≡ b(mod m), then for any positive integer k, ak ≡ bk (mod m).
9. We have a ≡ b(mod mi ), i = 1, ..., k, if and only if a ≡ b(mod lcm(m1 , ..., mk )).In
particular, if m1 , ..., mk are pairwise relatively prime, then a ≡ b(mod mi ),
i = 1, ..., k, if and only if a ≡ b(mod m1 ...mk ).
Remark. Residue system for a positive integer needs not to be unique. For
example, one can consider {8, 9, 10, 11, 12, 13, 14, 15} to be a residue system with
respect to 8 too - as the elements of this set are actually same as the elements
of the previous set if we consider them modulo 8.
Now, let us look into something more special. we will now consider a
residue system of 12 where the elements are strictly less than 12 - which is
S = {0, 1, 2, . . . , 11}. Now, some elements of this set are co-prime with 12 (Re-
call that if a and b has 1 as their Greatest Common Divisor, we call a and b
co-prime numbers). These numbers are 1, 5, 7, 11. If we consider these numbers
as elements of a specific set, we call that set a Reduced Residue System modulo
12.
3
Generally speaking, a Reduced Residue System of a positive integer n will be
the set of positive integers where (i) each element is strictly less than n and
(ii) each element is co-prime with n.For brevity, we will call this set the RRS
modulo n.
For example, residue set for 8 is {0, 1, 2, 3, 4, 5, 6, 7} and so the RRS modulo
8 will be {1, 3, 5, 7}. Similarly, residue system of 14 is {0, 1, 2, 3, . . . , 13} which
implies that RRS modulo 14 is {1, 3, 5, 9, 11, 13}.
3.1 Exercises
1. Find out the RRS’ for the following cases: (i) modulo 16 (ii) modulo 23
(iii) modulo 24.
2. What will one get when considering the RRS modulo a prime?
3. Suppose {a1 , a2 , a3 , . . . , an } is an RRS modulo m. Show that {ka1 , ka2 , ka3 , . . . , kan }
is also an RRS modulo m for any integer k co-prime with m.
1 2 3 ... a
a+1 a+2 a+3 ... 2a
.. .. .. .. ..
. . . . .
a(b − 1) + 1 a(b − 1) + 2 a(b − 1) + 3 ... ab
4
Clearly, there are φ(ab) numbers in the above table that are relatively prime (in
other words, co-prime) to ab.
On the other hand, there are φ(a) columns containing those elements in the table
which are co-prime to a. Each of those columns is a complete residue system
modulo b. Hence there are exactly φ(b) elements in each of those columns that
are co-prime to b. Therefore, there are φ(a)φ(b) numbers in the table that are
relatively prime to ab.
Hence φ(ab) = φ(a)φ(b) for relatively prime integers a, b.
The last property can be extended to produce a stronger and more gener-
alised property, which we show below. Readers are encouraged to ponder over
the procedures to prove it.
We will end this section with a final property, which makes finding out the
values of totient functions of integers which contains large powers of primes
WAY easier.
Proof. There are pk positive integers less than or equal to pk . Among these
integers those who are not co-prime with pk are p, 2p, 3p, . . . , pk−1 .p - which
means pk−1 numbers. So, there are (pk − pk−1 ) numbers co-prime with pk ,
which proves the property.
5 Euler’s Theorem
Euler’s theorem shows why totient functions are really useful in the realms of
modular arithmetic. The theorem is as follows:
5
As gcd(ai , m) for 0 ≤ i ≤ φ(m), using basic property 7 of congruence, we can
cancel out all the ai ’s from both sides, which will finally yield aφ(m) ≡ 1 (mod
m).
Now if we replace m in Euler’s theorem with a prime number p, we get a
much more convenient form (Recall that φ(p) = p − 1). This form is popularly
known as Fermat’s Little Theorem, which we show below:
Theorem 2. (Fermat’s Little Theorem) If p is a prime and a is an integer
co-prime with p, then ap−1 ≡ 1 (mod p). This can also be written as ap ≡ a
(mod p)
6 Walkthroughs
Problem 6.1. Find the remainder when 2910 is divided by 9.
Solution. Okay so, if you were a person who didn’t know modular arithmetic,
you’d probably be intimidated because 2910 is something you cant possibly cal-
culate if you didn’t have a calculator. But, with modular arithmetic, it’s pretty
easy: