An Introduction To Modular Arithmetic
An Introduction To Modular Arithmetic
Brandon Jiang
May 15, 2016
1 Introduction
Modular arithmetic is an important topic in number theory dealing largely with the study of remainders.
This approach is extremely useful in a variety of difficult problems.
2 Definition
We say that a is the modulo-m residue of n when n ≡ a (mod m), and
0 ≤ a < m.
This is identical to saying that a is the remainder when n is divided by m.
Theorem 2.2 For a prime m, each integer in {2, · · ·, m − 2} has a unique inverse modulo-m in the same
set.
The rigorous proof of this theorem a bit contrived, which is why it is not included. However, this fact should
be quite intuitive, especially given Bézout’s Identity. Notice how 1 and m − 1 are excluded. This is because
1 and m − 1 are their own inverses modulo-m.
Theorem 2.3 (Wilson) Given a prime p, (p − 1)! ≡ −1 (mod p).
Proof By Theorem 2.2, since each integer in {2, · · ·, m − 2} is paired with it’s inverse and 1 ≡ 1 (mod p),
we know that (p − 2)! ≡ 1 (mod p). Also, because p − 1 ≡ −1 (mod p), we can multiply the two to get
the desired expression.
1
Proof Let n and k be integers such that a − b = mn and c − d = mk. Adding these equations gives
(a − b) + (c − d) = mn + mk
(a + c) − (b + d) = m(n + k)
(a − b) − (c − d) = mn − mk
(a − c) − (b − d) = m(n − k)
Proof Again, we let a − b = mn. Multiplying both sides by c, we have that ac − bc = mnc, and therefore
ac ≡ bc (mod m). Similarly, we can multiply both sides of the congruence c ≡ d (mod m) by b to get
bc ≡ bd (mod m). Rewriting these as equations and adding them gives
ac − bc = mnc
bc − bd = mkb
ac − bd = m(nc + kb)
Since a and b are divisible by e, we can write a = pe and b = qe for integers p and q. We rewrite the
congruence as pe ≡ qe (mod m). Following from Bézout’s Identity, there exists an integer e0 such that
ee0 ≡ gcd(m, e) (mod m). Multiplying with the previous congruence, we have
Proof We will proceed with induction. The base case, a ≡ b (mod m) is given. Now let us assume
that ak ≡ bk (mod m). By Theorem 3.3, we can multiply corresponding terms with the base case to get
ak+1 ≡ bk+1 (mod m). This completes the inductive step, and the conclusion follows.
2
4 Linear Congruences
A linear congruence is a modular congruence of the form ax + b ≡ c (mod m). Solving for x is similar to
solving a linear equation. Solving congruences involves the above properties. A notable strategy is to use
the fact that m ≡ 0 (mod m) and adding multiples of m to both sides of the equation.
Example 4.1 Solve the linear congruence for x.
5x + 12 ≡ 3 (mod 8)
We can manipulate the congruence
5x + 4 ≡ 11 (mod 8)
5x ≡ 7 (mod 8)
5x ≡ 15 (mod 8)
x≡3 (mod 8)
When we have more than one equation, we have a linear congruence system.
Example 4.2 There are a certain number of people in the school band. If the members try to line up in 14
equal rows, then 1 person is left over. If they line up in 15 equal rows, then 2 people are left over. If there
are more than 200 people in the band, what is the fewest possible number of people in the band?
We can express this information in the form of two linear congruences. Let N be the number of people in
the band.
N ≡ 1 (mod 14)
N ≡2 (mod 15)
Adding 13 to both equations, we have
N + 13 ≡ 0 (mod 14)
N + 13 ≡ 0 (mod 15)
Thus, we know that N + 13 is a multiple of 14 and 15. The least positive value of N satisfying this condition
is 14 · 15 − 13 = 197, however the problem states that there are more than 200 people. Therefore, we look
for the next largest which is 2(14 · 15) − 13 = 407 people.
5 Residue Classes
Given integers m and n, the quadratic residues are the possible values p where n2 ≡ p (mod m). As an
example, consider the case n2 ≡ p (mod m). Since we are working modulo-3, we know that n ≡ 0, 1, 2
(mod 3). Taking each case individually,
3
6 Challenge Problems
1. If n = (1 + 2 + · · · + 48)49 , what is the remainder when n is divided by 50?
2. The Fibonacci sequence is defined F0 = F1 = 1 and Fn+2 = Fn+1 + Fn . Find the remainder when F200
is divided by 8.
3. Two random integers, a and b, are independently chosen, with replacement, from 1 to 1000, inclusive.
What is the probability that both 2a + 2b and 3a + 3b are multiples of 5? Express your answer as a
common fraction. (Source: MATHCOUNTS)
4. Find the number of ordered quadruples (a, b, c, d) of positive integers such that a2 +b2 +c2 +d2 = 9·22015 .
(Source: Clevermath)
5. Find the number of solutions to y 2 = x5 − 4 in integers.
6. Ms. Math’s kindergarten class has 16 registered students. The classroom has a very large number, N ,
of play blocks which satisfies the conditions: (a) If 16, 15, or 14 students are present, then in each case
all the blocks can be distributed in equal numbers to each student, and (b) There are three integers
0 < x < y < z < 14 such that when x, y, or z students are present and the blocks are distributed in
equal numbers to each student, there are exactly three blocks left over.
Find the sum of the distinct prime divisors of the least possible value of N satisfying the above
conditions. (Source: AIME)