Number theory lectures
By Dr. Mohammed M. AL-Ashker
Associated professor
Mathematics Department
E.mail:mashker @ mail.iugaza.edu
Islamic University of Gaza P.O.Box 108, Gaza, Palestine
1
Contents
1 Divisibility Theory of integers
1.1 The Division Algorithm . . . . .
1.2 The greatest common divisor . .
1.3 The Euclidean algorithm . . . . .
1.4 The Diophantine equation ax + by
.
.
.
.
3
3
4
8
11
2 Primes and their distributions
2.1 Fundamental theorem of arithmetics . . . . . . . . . . . . . . .
2.2 The sieve of Eratosthenes . . . . . . . . . . . . . . . . . . . . .
2.3 The Goldbach conjecture . . . . . . . . . . . . . . . . . . . . . .
14
14
16
17
3 The
3.1
3.2
3.3
. . .
. . .
. . .
=c
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
theory of congruences
19
Basic properties of congruence . . . . . . . . . . . . . . . . . . . 19
Special divisibility tests . . . . . . . . . . . . . . . . . . . . . . . 23
Linear congruences . . . . . . . . . . . . . . . . . . . . . . . . . 25
4 Fermat’s theorem
31
4.1 Fermat’s little theorem . . . . . . . . . . . . . . . . . . . . . . . 31
4.2 Wilson’s theorem . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2
Chapter 1
Divisibility Theory of integers
1.1
The Division Algorithm
Theorem 1.1.1. Given integers a and b, with b > 0, there exist unique integers
q and r satisfying, a = qb + r , 0 ≤ r < b. The integers q and r
are called, respectively, the quotient and remainder in the division of a and b.
Proof. We first Show r and q exist. Let S = {a − xb : a − xb ≥ 0, x ∈
Z}. We will show that S 6= φ. Since b > 0 and b ∈ Z =⇒ b ≥ 1 =⇒
|a|b ≥ |a|. Let x = −|a| =⇒ a − xb ≥ a + |a|b ≥ a + |a| ≥ 0 =⇒ S 6=
φ (S not empty), so S contains a least non-negative integer call it r.
Then r will be in the form r = a−qb, then r exists and also q exists corresponding to r.
We will also show that r < b.
Suppose r ≥ b and r = r0 + b where r0 ≥ 0 and r0 + b = a − qb =⇒ r0 =
a − (q + 1)b ≥ 0 =⇒ r0 ∈ S.
Contradiction, (because r0 < r and r the smallest non-negative element in S) =⇒
0 ≤ r < b.
We will now prove the uniqueness of r and q. Assume ∃r1 , q1 satisfying the conditions of the theorem such that r < r1 and a = q1 b+r1 then r1 = a−q1 b.....(1)
but a = qb + r then r = a − qb....(2), from (1) and (2) by subtraction, we have
(r1 − r) = (q − q1 )b =⇒ b|r1 − r.
Contradiction, because r1 < b and r < b =⇒ r1 − r = 0 =⇒ r1 = r and q1 =
q.
Example 1.1.1. If a = 592, b = 7 then 592 = 84(7) + 4 then q = 84 and
r = 4.
3
Corollary 1.1.2. If a and b are integers, with b ≥ 0, then there exist unique
integers q and r such that,
a = qb + r, 0 ≤ r < |b|.
Proof. If b < 0, then |b| > 0 and by the above theorem ∃q 0 and r 3 a =
q 0 |b| + r, 0 ≤ r < |b|.
Since |b| = −b, we may take q = −q 0 to arrive a = (−q)(−b) + r = qb + r with
0 ≤ r < |b|.
Example 1.1.2. Let b = −7, a = 1 then 1 = 0(−7) + 1, where 0 ≤ r = 1 <
|b| = 7.
Let b = −7, a = −2 then − 2 = 1(−7) + 5, where 0 ≤ r = 5 < |b| = 7.
Let b = −7, a = 61 then 61 = (−8)(−7) + 5, where 0 ≤ r = 5 < |b| = 7.
Let b = −7, a = −59 then − 59 = 9(−7) + 4, where 0 ≤ r = 4 < |b| = 7.
If a is even integer then a = 2q and a2 = 4q 2 = 4k where k = q 2 . If a is odd
then a = 2q +1 and a2 = 4q 2 +4q +1 = 4(q 2 +q)+1 = 4k 0 +1 where k 0 = q 2 +q.
Example 1.1.3. The square of any odd integer is of the form 8k + 1
Proof. By division algorithm, any integer is represented as one of the four
following forms: 4q, 4q + 1, 4q + 2, 4q + 3. In this classification, only those
integers of the forms 4q +1 and 4q +3 are odd. Then 4q +1)2 = 16q 2 +8q +1 =
8(2q62 + q) + 1 = 8k + 1, where k = 2q 2 + q,and (4q + 3)2 = 16q 2 + 24q + 9 =
8(2q 2 + 3q + 1) + 1 = 8k 0 + 1, wherek 0 = 2q 2 + 3q + 1.
Let a = 7 then a2 = 49 = 8 · 6 + 1.
1.2
The greatest common divisor
Definition 1.2.1. An integer b is said to be divisible by an integer a 6= 0, in
symbols a|b, if there exists some integer c such that b = ac. We write a - b to
indicate that such b is not divisible by a.
Example 1.2.1. 3| − 12 because −12 = 4(−3) but 3 - 10 @c ∈ Z 3 10 = 3c.
If a|b =⇒ −a|b because if b = ac =⇒ b = −a(−c) =⇒ −a|b.
Theorem 1.2.1. For integers a, b and c the following hold :
4
1) a|0, 1|a, a|a.
2) a|1 if and only if a = ±1.
3) If a|b and c|d, then ac|bd.
4) If a|b and b|c, then a|c.
5) a|b and b|a if and only if a = ±b.
6) If a|b and b 6= 0 then |a| ≤ |b|.
7) If a|b and a|c then a|bx + cy for arbitrary integers x and y.
Proof.
1) For a|0, ∃x = 0, 3 0 = 0a. For 1|a, ∃x = a, 3 a = a1. For a|a,
∃x = 1, 3 a = 1a.
2) If a|1, then ∃x ∈ Z 3 1 = ax =⇒ x = ±1 or a = ±1
3) If a|b and c|d,then ∃x, y ∈ Z 3 b = xa, d = cy =⇒ bd = xyca =⇒ ca|bd.
4) If a|b and b|c then ∃x, y ∈ Z 3 b = ax, c = by then c = axy =⇒ a|c.
5) If a|b and b|a then ∃x, y ∈ Z 3 b = ax, a = by =⇒ b = byx =⇒ 1 =
yx =⇒ y = ±1, x = ±1 =⇒ b = ±a.
6) If a|b then there exists c ∈ Z such that b = ac, also b 6= 0 then c 6=
0, and |b| = |ac| = |a||c|, since c 6= 0 then |c| ≥ 1 and |b| ≥ |a||c| ≥ |a|.
7) If a|b and a|c then there exists t ∈ Z, r ∈ Z, 3 b = at and c = ar =⇒
bx = atx, cy = ary =⇒ bx + cy = a(tx + ry) =⇒ a|bx + cy.
In general if a|bk for k = 1, 2, · · · , n then a|b1 x1 + b2 x2 + · · · + bn xn .
Definition 1.2.2. The integer d is a common divisor of a and b in case d|a,
and d|b.
since 1|a for any integer a then 1 is a common divisor of a and b, so the set of
common divisors of any integers a and b is non empty.
Remark 1.2.1. If a = b = 0, then every integer is a common divisor of a and
b, so in this case the set of common divisors of a and b is infinite.
If at least one of a or b is not zero then there are only a finite number of
positive common divisors.
5
The largest common divisor which is called the greatest common divisor which
denoted by g.c.d(a, b).
Definition 1.2.3. Let a and b be given integers with at least one of them
different from zero. The g.c.d(a, b) is the positive integer d satisfying:
1) d|a and d|b.
2) If c|a and c|b, then c ≤ d.
Example 1.2.2. The positive divisors of −12 are 1, 2, 3, 4, 6, 12 wile those of
30 are 1, 2, 3, 5, 6, 10, 15, 30. the g.c.d(30, −12) = 6.
g.c.d(−5, 5) = 5, g.c.d(8, 17) = 1 and g.c.d(−8, −36) = 4.
If a = b = 0 there is no greatest common divisor.
If we have a1 , a2 , · · · , an such that at least one of ai 6= 0 for i = 1, 2, · · · , n
then g.c.d of ai 6= 0 for i = 1, 2, · · · , n is denoted by g.c.d(a1 , a2 , · · · , an ).
Theorem 1.2.2. Given integers a and b not both of which are zero, there exist
integers x and y such that g.c.d(a, b) = ax + by.
Proof. Let g = g.c.d(a, b), let S = {ax + by : x, y ∈ Z and ax + by > 0}. Since
−a+b, a−b, −a−b, a+b are integers, so at least one of them must be in S =⇒
S 6= ∅. Let l = the smallest positive integer in S chose x0 , y0 , So that
l = ax0 + by0 we will show that l|a, and l|b. Assume that l - a =⇒ ∃q and r ∈
Z 3 a = lq + r, 0 < r < l =⇒ r = a − lq = a − q(ax0 + by0 ) =
a(1 − qx0 ) + b(−qy0 ) =⇒ r ∈ S, Contradiction, because r < l and l is the
smallest integer in S =⇒ r = 0 and l|a.....(1).
By the same way we can prove that l|b.....(2)
then from (1) and (2) =⇒ l is a common divisor of a and b.
Since g = g.c.d(a, b) =⇒ g|a, g|b =⇒ g|ax0 + by0 = l =⇒ g|l, g ≤ l,
but l is a common divisor of a and b cannot be greater than the g.c.d g =⇒
g = l.
Corollary 1.2.3. If a and b are given integers, not both zeros, then the set
T = {ax + by|x, y are integers} is precisely the set of all multiples of g =
g.c.d(a, b).
Proof. Since g|a, and g|b =⇒ g|ax + by for all integers x, y ∈ Z. Then every
member of T is a multiple of g. If g = ax0 + by0 for suitable integers x0 and y0 .
So that any multiple ng of g is of the form ng = n(ax0 + by0 ) = a(nx0 ) +
6
b(ny0 ) =⇒ ng is a linear combination of a and b and by definition lies in
T.
Remark 1.2.2. If an integer g is expressible in the form g = ax + by then it is
not necessary that g is the g.c.d of (a, b). But it follows from such an equation
g.c.d (a, b)|g.
If ax + by = 1 for some integers x and y then g.c.d(a, b) = 1.
Definition 1.2.4. Two integers a and b, not both of which are zeros, are said
to be relatively prime whenever g.c.d(a, b) = 1.
Example 1.2.3. g.c.d(2, 5) = g.c.d(−9, 16) = g.c.d(−27, −35) = 1
Theorem 1.2.4. Let a and b integers not both zeros, then a and b are relatively
prime if and only if there exist integers x and y such that 1 = ax + by.
Proof. If g.c.d(a, b) = 1, then ∃x, y ∈ z 3 1 = ax + by.
Conversely if 1 = ax+by for some x, y ∈ Z, and g = g.c.d(a, b) =⇒ g|a, g|b =⇒
g|ax + by =⇒ g|1 =⇒ g = 1 =⇒ a and b are relatively prime.
Corollary 1.2.5. If g.c.d(a, b) = d, then g.c.d( ad , db ) = 1.
Proof. d|a, d|b =⇒ ad , db are integers since d = g.c.d(a, b) =⇒ ∃x, y ∈ Z 3
d = ax + by =⇒ 1 = ad x + db y, by previous theorem ( ad , db ) = 1.
Example 1.2.4. g.c.d(−12, 30) = 6 =⇒ g.c.d( −12
, 30
) = g.c.d(−2, 5 = 1
6
6
Remark 1.2.3. It is not true that if a|c and b|c =⇒ ab|c. For example 6|24, and 8|24 =⇒
48 - 24.
Corollary 1.2.6. If a|c and b|c with g.c.d(a, b) = 1 =⇒ ab|c.
Proof. If a|c, b|c, ∃r and s ∈ Z 3 c = ar = bs, since g.c.d(a, b) = 1 then there exist x, y ∈
Z 3 1 = ax + by =⇒ c = cax + cby = acx + bcy =⇒ c = a(bs)x + b(ar)y =
ab(ax + ry) =⇒ ab|c.
Theorem 1.2.7. If a|bc with g.c.d(a, b) = 1, then a|c.
Proof. Since g.c.d(a, b) = 1 =⇒ ∃x, y ∈ Z 3 1 + ax + by =⇒ c = acx +
bcy since a|ac and a|bc =⇒ a|acx+bcy =⇒ a|c(ax+by) =⇒ a|c·1 =⇒ a|c.
Remark 1.2.4. If g.c.d(a, b) 6= 1 then a - c
7
Example 1.2.5. 12|9 · 8 =⇒ 12 - 9, 12 - 8.
Theorem 1.2.8. Let a, b be integers, no both zero. For a positive integer
d, d = g.c.d(a, b) if and only if
1) d|a and d|b,
2) wherever c|a and c|b, then c|d.
Proof. Let d = g.c.d(a, b) =⇒ d|a, and d|a, d|b, so (a) holds. Also ∃x, y ∈
Z 3 d = ax + by. If c|a, c|b then c|ax + by =⇒ c|d =⇒ condition (2) holds.
Conversely, let d be any positive integer satisfying the stated conditions and
let c be any common divisor of a and b then c|d by condition (2). This implies
that d ≥ c, so d is the greatest common divisor of a and b.
1.3
The Euclidean algorithm
Lemma 1.3.1. If a = qb + r, then g.c.d(a, b) = g.c.d(b, r).
Proof. If d = g.c.d(a, b) =⇒ d|a, d|b =⇒ d|a−qb = r, =⇒ d|r =⇒ d|g.c.d(b, r), let c =
g.c.d(b, r) =⇒ d|c....(1).
c|b, c|r =⇒ c|bq+r =⇒ c|a =⇒ c|g.c.d(b, a) = d =⇒ c|d....(2). from (1), (2) =⇒
c = d.
Theorem 1.3.2. The Euclidean algorithm.
Let a and b be two integers whose greatest common divisor is desired. Assume
that a ≥ b > 0. Apply the division algorithm to a and b to get,
a = q1 b + r1 , 0 ≤ r1 < b.
If r1 = 0 =⇒ b|a and g.c.d(a, b) = b.
If r1 =
6 0 divide b by r1 to produce integers q2 and r2 satisfying
b = q2 r 1 + r 2 , 0 ≤ r 2 < r 1 .
If r2 = 0, then we stop; otherwise, proceed as before to obtain
r1 = q3 r2 + r3 , 0 ≤ r3 < r2 .
This division process continues until some zero remainder appears, say at the
(n+1)th stage where rn−1 is divided by rn (a zero remainder occurs sooner or
8
later, since the decreasing sequence b > r1 > r2 > · · · ≥ 0 cannot contain more
than b integers.
The result is the following system of equations.
a = q1 b + r1 ,
0 < r1 < b
b = q2 r1 + r2 ,
o < r 2 < r1
r1 = q3 r2 + r3 ,
o < r 3 < r2
..
..
.
.
rn−2 = qn rn−1 + rn , 0 < rn < rn−1
rn−1 = qn+1 rn + 0.
We argue that rn , the last nonzero remainder which appears in this manner is
equal to g.c.d(a, b).
Proof. By lemma
g.c.d(a, b) = g.c.d(b, r1 ) = · · · = g.c.d(rn−1 , rn ) = g.c.d(rn , 0) = rn .
The g.c.d(a, b) can be expressed in the form ax + by. For this, we fall back
on Euclidean algorithm. Starting with the next-to-last equation arising from
the algorithm, we write
rn = rn−2 − qn rn−1 .
Now solve the proceeding equation in the algorithm for rn−1 and substitute to
obtain,
rn = rn−2 − qn (rn−3 − qn−1 rn−2 ) = (1 + qn qn−1 )rn−2 + (−qn )rn−3 .
This represents rn as a linear combination of rn−2 and rn−3 . Continuing backwards through the system of equations, we successively eliminate the remainders rn−1 , rn−2 , · · · , r2 , r1 until a stage is reached where rn = g.c.d(a, b) is
expressed as a linear combination of a and b.
Example 1.3.1. Use Euclidean algorithm to find the greatest common divisor
of 7469 and 2464.
solution:
7469 = 3(2464) + 77
2464 = 32(77) + 0
∴ g.c.d(7469, 2464) = 77.
Also 77 = 7469 − 3(2464), so x = 1, y = −3.
9
Theorem 1.3.3. If k > 0, then g.c.d (ka, kb) = k g.c.d (a, b).
Proof. Let g = g.c.d(a, b) then g = the least positive value of ax + by. So for
k > 0, g.c.d(ka, kb) = least positive value of (kax + kby) =
k (least positive value of ax + by) = k g.c.d(a, b) = kg.
Corollary 1.3.4. For any integer k 6= 0, g.c.d(ka, kb) = |k|g.c.d(a, b).
Proof. If k < 0 =⇒ |k| = −k =⇒ g.c.d(ak, bk) = g.c.d(−ak, −bk) = g.c.d(a|k|, b|k|) =
|k|g.c.d(a, b).
Example 1.3.2. g.c.d(12, 30 = 3g.c.d(4, 10) = (3) · 2g.c.d(2, 5) = 6.
Definition 1.3.1. An integer c is said to be a common multiple of two nonzero
integers a and b whenever a|c and b|c. Evidently 0 is a common multiple of a
and b.
Example 1.3.3. For a = −12, b = 30, all of the integers 0, 60, 120, 180, · · ·
are common multiple of −12 and 30. The least positive common multiple
l.c.m(−12, 30) = 60.
Definition 1.3.2. The Least common multiple of two nonzero integers a and
b, denoted by l.c.m(a, b), is the positive integer m satisfying:
(1) a|m and b|m.
(2) if a|c and b|c, with c > 0, then m ≤ c.
Remark 1.3.1. If a, b 6= 0 then l.c.m(a, b) exists and l.c.m(a, b) ≤ |ab|.
Theorem 1.3.5. For positive integers a and b, g.c.d(a, b)l.c.m(a, b) = ab.
Proof. Let d = g.c.d(a, b) =⇒ d|a, d|b =⇒ ∃r, s ∈ Z 3 a = dr, b = ds. If
m = ab
, then m = as = br because m = drds
= as = br =⇒ a|m, b|m =⇒
d
d
m is a positive common multiple of a and b.
Now let c be any positive integer that is a common multiple of a and b then
a|c and b|c =⇒ c = au = bv for some u, v ∈ Z =⇒ u = ac , v = cb .
cd
Since d = g.c.d(a, b) =⇒ ∃x, y ∈ Z 3 d = ax + by, then mc = ab
= c(ax+by)
=
ab
c
c
x + a y = vx + uy ∈ Z =⇒ m|c =⇒ m ≤ c =⇒ m = l.c.m(a, b) and
b
ab
m = ab
= g.c.d(a,b)
=⇒ ab = md = l.c.m(a, b)g.c.d(a, b).
d
Corollary 1.3.6. Given positive integers a and b, l.c.m(a, b) = ab if and only
if g.c.d(a, b) = 1.
10
Proof. l.c.m(a, b)g.c.d(a, b) = ab if g.c.d.(a, b) = 1 then l.c.m(a, b) · 1 = ab.
Conversely, let l.c.m(a, b)g.c.d(a, b) = ab and l.c.m(a, b) = ab then abg.c.d(a, b) =
ab =⇒ g.c.d(a, b) = 1.
Example 1.3.4. Find l.c.m(7469, 2464).
solution: g.c.d(7469, 2464) by Euclidean algorithm is equal 77
(7469)(2464)
So l.c.m(7469, 2464) = g.c.d(7469,2464)
= 239008
Definition 1.3.3. If a, b, c ∈ Z not all zero then the g.c.d(a, b, c) is defined to
be the positive integer d having the properties:
(1) d is a divisor of each a, b, c
(2) If e divides the integers a, b, c then e ≤ d.
Example 1.3.5. g.c.d(39, 42, 54) = 3.
Definition 1.3.4. Three integers are said to be relatively prime as a triple if
g.c.d(a, b, c) = 1, yet not relatively primes in pairs.
1.4
The Diophantine equation ax + by = c
Theorem 1.4.1. The linear diophantine equation ax + by = c has a solution
if and only if d|c, where d = g.c.d(a, b). If x0 , y0 is any particular solution of
this equation, then all other solutions are given by
b
a
x = x0 + t, y = y0 − t for varying integer t.
d
d
Proof. Let d = g.c.d(a, b) =⇒ d|a, d|b =⇒ ∃r, s ∈ Z 3 a = dr, b = ds. If
ax + by = c has a solution then there exists x0 , y0 such that ax0 + by0 = c =⇒
drx0 + dsy0 = c =⇒ d(rx0 + sy0 ) = c =⇒ d|c.
Conversely if d|c =⇒ ∃t ∈ Z, 3 c = dt, but d = g.c.d(a, b) =⇒ ∃x0 , y0 ∈ Z 3
ax0 + by0 = d =⇒ atx0 + bty0 = td =⇒ a(tx0 ) + b(ty0 ) = c. If x = tx0 , y = ty0
then the diophantine equation ax + by = c has a solution x = tx0 , and y = ty0 .
To proof the second assertion of the theorem,
let x0 , y0 be a solution of the diophantine equation ax + by = c =⇒ ax0 + by0 =
c.
Let x0 , y 0 be any other solution, then ax0 + by 0 = c =⇒ ax0 + by0 = ax0 + by 0 =
c =⇒ a(x0 − x0 ) = b(y0 − y 0 ).
11
But d|a, and d|b =⇒ ∃r, s ∈ Z, 3 a = rd, b = ds =⇒ d = g.c.d(a, b) =
g.c.d(dr, ds) = dg.c.d(r, s) =⇒ g.c.d(r, s) = 1 =⇒ rd(x0 − x0 ) = sd(y0 − y 0 ) =⇒
r|s(y0 − y 0 ) but g.c.d(r, s) = 1 =⇒ r|(y0 − y 0 ) =⇒ ∃t ∈ Z, 3 y0 − y 0 = tr.
By substituting we have,
r(x0 − x0 ) = str =⇒ x0 − x0 = st =⇒ x0 = x0 + st = x0 + ( db )t and y 0 =
y0 − rt = y0 − ( ad )t.
It is only to show that these values satisfy the diophantine equation ax+by = c.
b
a
ab ab
ax0 + by 0 = a[x0 + t] + b[y0 − t] = ax0 + by0 + ( − )t = ax0 + by0 = c.
d
d
d
d
Therefore there are infinite number of solutions of the given equation, one for
each value of t.
Example 1.4.1. Determine all solutions in integers of the following Diophantine equation
56x + 72y = 40.
Solution:we apply Euclidian algorithm to find g.c.d(56, 72).
72 = 56 · 1 + 16
56 = 16 · 3 + 8
16 = 8 · 2 + 0.
Then g.c.d(56, 72) = 8, since 8|40, then the Diophantine equation has solution.
8 = 56 − 16 · 3
= 56 − (72 − 56)3
= 56(1 + 3) − 3(72)
= 4(56) − (3)72.
Then 40 = 20(56) − 15(72).
Then x0 = 20, y0 = −15 are the particular solutions and all solutions are x =
20 + 9t, y = −15 − 7t , where t ∈ Z.
Corollary 1.4.2. If g.c.d(a, b) = 1 and if x0 , y0 is a particular solution of the
linear diophantine equation ax + by = c, then all solutions are given by
x = x0 + bt, y = y0 − at for integral values of t.
12
Example 1.4.2. Find all solutions of the diophantine equation,
30x + 17y = 300.
Solution
30 = 17 · 1 + 13
17 = 13 · 1 + 4
13 = 4 · 3 + 1
4 = 4 · 1 + 0.
Then the g.c.d(30, 17) = 1. Then
1 = 13 − 4(3) = 13 − (17 − 13)(3) = 13(4) − 3(17) = (30 − 17)4 − 3(17)
1 = 4(30) − 7(17).
Then 300 = 1200(30) − 2100(17).
Then the particular solutions are x0 = 1200, y0 = −2100 and all solutions are x =
1200 + 17t, y = −2100 − 30t.
13
Chapter 2
Primes and their distributions
2.1
Fundamental theorem of arithmetics
Definition 2.1.1. An integer p > 1 is called a prime number, or simply a
prime, if its only positive divisors are 1 and p. An integer greater than 1 which
is not a prime termed composite.
Example 2.1.1. 2,3,5,7 are primes but 4,6,8,9,10 are composite. 2 is the only
even prime, and all other primes are odd.
Theorem 2.1.1. If p is a prime and p|ab, then p|a or p|b.
Proof. Assume that p - a =⇒
g.c.d(a, p) = p =⇒ p|a.
g.c.d(a, p) = 1 =⇒
if p|ab =⇒ p|b. if
Corollary 2.1.2. If p is a prime and p|a1 a2 · · · an , then p|ak for some k, where 1 ≤
k ≤ n.
Proof. Assume that p - ak for 1 ≤ k ≤ n =⇒ g.c.d(p, ak ) = 1 for 1 ≤ k ≤
n =⇒ g.c.d(p, a1 , a2 , · · · an ) = 1 =⇒ p - a1 a2 · · · an contradiction. So there
exists some k, 1 ≤ k ≤ n such that p|ak .
Corollary 2.1.3. If p, q1 , q2 , · · · , qn are all primes and p|q1 q2 · · · qn then p =
qk for some k, where 1 ≤ k ≤ n.
Proof. By previous corollary (2.1.2) ∃k, 1 ≤ k ≤ n 3 p|qk , being a prime, qk
is not divisible by any positive integer other than 1 or q itself, since p > 1 then
p = qk
14
Theorem 2.1.4. (Fundamental theorem of arithmetic) Every positive integer
n > 1 can expressed as a product of primes, this representation is unique, a
part from the order in which the factors occur.
Proof. If n is prime then done.
If n is composite then there exists a prime p1 such that,
n = p1 n1 , 1 < n1 < n. If n1 is prime done, if not there exists p2 and n2 such
that n1 = p2 n2 , 1 < n2 < n1 < n =⇒ n = p1 p2 n2 .
After k − 1 times we have,
n = p1 p2 · · · pk−1 nk−1 and 1 < nk < · · · < n2 < n1 < n, the sequence cannot
be infinite, so after nk−1 steps, nk−1 must be prime say nk−1 = pk =⇒ n =
p1 p2 · · · pk .
To establish the uniqueness, suppose that n has two representations as a product of primes, say
n = p1 p2 · · · pk = q1 q2 · · · qs , where k ≤ s and pi , qj are primes and p1 ≤ p2 ≤
· · · p k , q 1 ≤ q2 · · · ≤ qs .
Since p1 |q1 q2 · · · qs , there exists i, 1 ≤ i ≤ s such that p1 = qi ≥ q1 ,
similarly q1 ≥ p1 then q1 = p1 .
If s = k after repeated the same process k times we have unique representation
of n. If k < s then after k times we have p1 p2 · · · pk = p1 p2 · · · pk qk+1 qk+2 · · · qs
and by cancelling the common factors we obtain
1 = qk+1 qk+2 · · · qs which is a contradiction. Since qi > 1 then k = s and
p1 = q1 , · · · pk = qk . So n has unique representation.
Corollary 2.1.5. Any positive integer n > 1 can be written uniquely in a
canonical form
n = pk11 pk22 · · · pkr r ,
where, for i = 1, 2, · · · , r, each ki is positive integer and each pi is a prime, with p1 <
p2 < · · · < pr .
Example 2.1.2.
360 = 23 · 32 · 5, 4725 = 33 · 52 · 7, and 17460 = 23 · 32 · 5 · 72 .
√
Theorem 2.1.6. The number 2 is irrational number.
√
√
Proof. Suppose that 2 is rational number say 2 = ab , where a and b are both integers with
g.c.d(a, b) = 1.
15
Then a2 = 2b2 =⇒ b|a2 . If b > 1, then by the fundamental theorem of arithmetics, there exists a prime p 3 p|b =⇒ p|a2 =⇒ p|a =⇒ g.c.d(a, p) ≥ p,
contradiction unless b = 1. If b = 1 =⇒ a2 = 2 which is impossible because no
integer can be multiplied by itself to give 2.
Theorem 2.1.7. Suppose a and b are positive integers. Let the distinct primes
dividing a or b (or both) be p1 , p2 , · · · pn . suppose a = pj11 pj22 · · · pjnn and b =
pk11 pk22 · · · pknn (some of the j’s and the k’s may be zero). Let mi be the smaller
and Mi be the larger of ji and ki for i = 1, 2, · · · , n.
(a) a|b if and only if ji ≤ ki for i = 1, 2, · · · , n.
mn
1 m2
(b) g.c.d(a, b) = pm
1 p2 · · · pn .
Mn
1 M2
(c) l.c.m(a, b) = pM
1 p2 · · · pn .
2.2
The sieve of Eratosthenes
Theorem 2.2.1. If n is composite it must have a prime factor p ≤
√
n.
Proof. Let n be composite, then n = d1 d2 where d1 and d2 > 1. If d1 and
√
√
√
d2 > n then n = d1 d2 > ( n)2 = n which impossible. Suppose d ≤ n,
√
then d1 is either prime or else has a prime divisor p ≤ n.
Corollary 2.2.2. If the integer n > 1 has no prime divisor ≤
prime.
√
n, then n is
Example 2.2.1. Determine wether n = 1999 is prime number or composite
number.
√
√
Solution: n = 1999 < 45, then all of the primes 2, 3, 5, · · · , 43 < 45 are
not divisors of 1999 so n = 1999 is prime.
Theorem 2.2.3. (Euclid)There are an infinite number of primes.
Proof. Suppose that p1 , p2 , · · · , pr are a finite number of primes.
Let n = 1 + p1 p2 · · · pr . Since n > 1, then if p is a prime number and
p|n, then p is one of the primes p1 , p2 , · · · , pr because =⇒ p|p1 p2 · · · pr =⇒
p|n − p1 p2 · · · pr =⇒ p|1 =⇒ p = 1, a contradiction because p > 1. So
p dose not belong to set of primes p1 , p2 , · · · , pr , so the number of primes is
infinite.
16
Remark 2.2.1. If pn is the nth prime number in the natural order then
pn+1 ≤ p1 p2 · · · pn + 1 for n ≥ 1.
For example if n = 3 then p4 = 7 ≤ p1 p2 p3 + 1 = (2) · (3) · (5) + 1 = 31.
The above estimation is wide; a sharper limitation to this size of pn is given
in the following theorem.
n−1
Theorem 2.2.4. If pn is the nth prime number, then pn ≤ 22
.
0
Proof. By induction on n. If n = 1, then p1 = 22 = 21 = 2 =⇒ p1 ≤ 2.
n−1
Assume that the result is true for n > 1,then pn ≤ 22 . We will show the
result is true for n + 1.
Since
pn+1 ≤ p1 p2 · · · pn + 1
2
n−1
≤ 2 · 22 · 22 · · · 22
2 +···2n−1
+ 1 = 21+2+2
+ 1.
And since 1 + 2 + 22 + · · · 2n−1 = 2n − 1, then
pn+1 ≤ 22
n −1
But 1 ≤ 22
n −1
+ 1.
for all n > 1, then,
n −1
pn+1 ≤ 22
n −1
+ 22
n −1
= 2 · 22
n
= 22 .
So the result is true for n + 1.
n
Corollary 2.2.5. For n ≥ 1, there are at least n + 1 primes less than 22 .
n
Proof. p1 , p2 , · · · , pn+1 are all less than 22 .
2.3
The Goldbach conjecture
Lemma 2.3.1. The product of two or more integers of the form 4n + 1 is of
the same form.
Proof. Let k = 4n + 1 and k 0 = 4m + 1 then k · k 0 = (4n + 1)(4m + 1) =
16nm + 4n + 4m + 1 = 4(4nm + n + m) + 1 which is of the desired form.
Theorem 2.3.2. There is infinite number of primes of the form 4n + 3
17
Proof. Assume that there exist only finitely many primes of the form 4n + 3,
call them q1 , q2 , · · · qs . Consider the positive integer
N = 4q1 q2 · · · qs − 1 = 4(q1 q2 · · · qs − 1) + 3
and let N = r1 r2 · · · rt be its prime factorization. Since N is odd integer, we
have rk 6= 2 for all k, so that each rk is either of the form 4n + 1 or 4n + 3. By
previous lemma, the product of any number of primes of the form 4n + 1 is
again an integer of this type. For N to take the form 4n + 3, as it clearly does,
N must contain at leat one prime factor ri of the form 4n+3. But ri cannot be
found among the listing q1 , q2 , · · · qs for this would lead to the contradiction
that ri |1. The only possible conclusion is that there are infinitely many primes
of this form 4n + 3.
Theorem 2.3.3. If a and b are relatively prime positive integers then the
arithmetic progression
a, a + b, a + 2b, · · ·
contains infinitely many primes.
Proof. Suppose that p = a + nb, where p is prime. If nk = n + kp, for k =
1, 2, 3, · · · then the nk th term in the progression is
a + nk b = a + (n + kp)b = (a + nb) + kpb = p + kpb =⇒ p|a + nk b.
So the arithmetic progression must contain infinitely many composite numbers
which are divisible by infinitely prime numbers.
18
Chapter 3
The theory of congruences
3.1
Basic properties of congruence
Definition 3.1.1. Let n be a fixed positive integer. Two integers a and b are
said to be congruent modulo n, symbolized by a ≡ b (mod n) if n divides the
difference a − b; that is provided that a − b = kn for some integer k.
Example 3.1.1. If n = 7 then 3 ≡ 24( mod 7), and −31 ≡ 11( mod 7).
If n - (a − b), then we say that a is not incongruent to b modulo n and
in this case we write a 6≡ b (mod n). For example 25 6≡ 12 (mod 7) since 7 (25 − 12) = 13.
Remark 3.1.1.
(1) Any two integers are congruent modulo 1.
(2) Two integers are congruent modulo 2 when they are both even or both
odd.
(3) Given integer a, let q and r be its quotient and remainder upon division
by n, so that
a = nq + r, 0 ≤ r < n =⇒ a − r = nq =⇒ n|a − r =⇒ a ≡ r (mod n).
There are n choices of r, r = 0, 1, · · · , n − 1. So every integer a is
congruent modulo n to exactly one of the numbers 0, 1, 2, · · · , n − 1.
and a ≡ 0 (mod n) ⇔ n|a.
The set of n integers 0, 1, 2, · · · n − 1 is called the set of least positive
residues modulo n.
19
Definition 3.1.2. The set of n integers a1 , a2 , a3 , · · · an is said to form a
complete residues set (or a complete residue system) modulo n if every integer
y is congruent modulo n to one and only one of the ai for 1 ≤ i ≤ n
i;e the set {a1 , a2 , a3 , · · · an } is called complete residue set modulo n if
∀y ∈ Z, ∃ one and only one ai , 1 ≤ i ≤ n 3 y ≡ ai (mod) n.
Example 3.1.2. Any integers a1 , a2 , · · · an are congruent modulo to 0, 1, 2, · · · n−
1, taken in some order.
Example 3.1.3. −12, −4, 11, 13, 22, 82, 91 constitute a complete set of residues
modulo 7, because −12 ≡ 2, −4 ≡ 3, 11 ≡ 4, 13 ≡ 6, 22 ≡ 1, 82 ≡ 5 and 91 ≡
0 all modulo 7.
Remark 3.1.2. Any n integers from a complete residue set modulo n if and
only if no two of the integers are congruent modulo n.
Theorem 3.1.1. For arbitrary integers a and b, a ≡ b (mod n) if and only if
a and b leave the same nonnegative remainder when divided by n.
Proof. Let a ≡ b (mod n) =⇒ n|a − b, so ∃k ∈ Z 3 a − b = nk =⇒ a = b + nk
by division algorithm
b = qn + r, 0 ≤ r < n so n leaves the remainder r,
then
a = b + kn = (qn + r) + kn = (q + k)n + r =⇒ a has the same remainder as b.
conversely, suppose that
a = q1 n + r, b = q2 n + r 3 0 ≤ r < n.
Then
a − b = (q1 n + r) − (q2 n + r) = (q1 − q2 )n =⇒ n|a − b =⇒ a ≡ b (mod n).
Example 3.1.4.
−56 ≡ (−7)9 + 7
−11 ≡ (−2)9 + 7,
then by the above theorem (3.1.1)
−56 ≡ −11 (mod 9).
20
Theorem 3.1.2. Let n > 0 be fixed and a, b, c, d be arbitrary integers. then
the following properties hold:
(1) a ≡ a (mod n).
(2) If a ≡ b (mod n), then b ≡ a (mod n)
(3) If a ≡ b (mod n) and b ≡ c (mod n), then a ≡ c(mod n).
(4) If a ≡ b (mod n) and c ≡ d (mod n), then a+c ≡ b+c (mod n) and ac ≡
bd (mod n).
(5) If a ≡ b (mod n), then a + c ≡ b + c (mod n) and ac ≡ bc (mod n).
(6) If a ≡ b (mod n), then ak ≡ bk (mod n) for any positive integer k.
Proof.
(1) a − a = 0 =⇒ n|a − a =⇒ a ≡ a (mod n).
(2) n|a − b =⇒ ∃k ∈ Z 3 a − b = nk =⇒ b − a = −kn =⇒ n|b − a =⇒ b ≡
a (mod n).
(3) Suppose that
a ≡ b (mod n) and b ≡ c (mod n) then there exist integers h and k satisfying
a − b = nk and b − c = kn. It follows that a − c = (a − b) + (b − c) =
hn + kn = (h + k)n, =⇒ n|a − c =⇒ a ≡ c (mod n).
(4) If a ≡ b (mod n) and c ≡ d (mod n), then ∃k1 , k2 ∈ Z 3 a − b =
k1 n, c − d = k2 n =⇒ (a + c) − (b + d) = k1 n + k2 n = (k1 + k2 )n =⇒
a + b ≡ (b + d) (mod n).
For the second assertion of (4)
ac = (b + k1 n)(d + k2 n) = bd + (bk2 + dk1 + k1 k2 n)n =⇒ ac ≡ bd (mod n).
(5) a ≡ b (mod n), then n|a − b =⇒ n|(a + c) − (b + c) also n|ca − cb ∀c ∈
Z =⇒ a + c ≡ b + c (mod n) and ca ≡ bc (mod n).
(6) For k = 1 the result holds.
Assume it is true for n = k =⇒ ak ≡ bk (mod n), then by (4) since
a ≡ b (mod n) =⇒ a · ak ≡ b · bk (mod n) =⇒ ak+1 ≡ bk+1 (mod n). So
it is true for n = k + 1. So the induction step is complete.
21
Example 3.1.5. Show that 220 ≡ 1 (mod 41).
Solution: 25 ≡ 32 ≡ −9 (mod 41) =⇒ 220 = (25 )4 ≡ (−9)4 (mod 41) ≡
(81)(81) ≡ (−1)(−1) ≡ 1 (mod 41).
Example 3.1.6. Find the remainder obtained upon dividing the sum
1! + 2! + 3! + 4! · · · 99! + 100! by 12.
Solution:
f ork ≥ 4, 4! ≡ 0 (mod 12) =⇒ k! · 5 · 6 · · · k ≡ 0(mod 12)
1! + 2! + 3! + 4! + · · · 100! ≡ 1 + 2 + 6 + 0 + · · · 0 ≡ 9 (mod 12).
So the sum leaves a remainder of 9 when divided by 12.
Remark 3.1.3.
If a ≡ b (mod n) =⇒ ac ≡ bc (mod n) but the converse need not true. for
example
2 · 4 ≡ 2 · 1 (mod 6) but 4 6≡ 1 (mod 6).
Theorem 3.1.3. If ca ≡ cb (mod n), then a ≡ b (mod nd ) where d = gcd(c, n).
Proof. If ca ≡ cb (mod n), then n|ca − cb =⇒ ∃k ∈ Z 3 c(a − b) = kn but
gcd(c, n) = d =⇒ gcd( dc , nd ) = 1 =⇒ dc (a − b) = k nd =⇒ nd | dc (a − b).
But gcd( dc , nd ) = 1, so by previous theorem nd |(a − b) =⇒ a ≡ b (mod nd ).
Corollary 3.1.4. If ca ≡ cb (mod n) and gcd(c, n) = 1 then a ≡ b (mod n).
Proof. If ca ≡ cb (mod n) then n|ca − cb = c(a − b) but gcd (n, c) = 1 =⇒
n|a − b =⇒ a ≡ b (mod n).
Corollary 3.1.5. If ca ≡ cb (mod p), where p is prime number and
p - c then a ≡ b (mod p).
Proof. p - c =⇒ gcd(p, c) = 1 and p|ca − cb = c(a − b) =⇒ p|a − b =⇒ a ≡
b (mod p).
Example 3.1.7. 33 ≡ 15 (mod 9) =⇒ 3 · 11 ≡ 3 · 5(mod 9) and gcd(3, 9) =
3 =⇒ 11 ≡ 5 (mod 3).
Example 3.1.8. −35 ≡ 45 (mod 8) then 5(−7) ≡
gcd(5, 8) = 1 then −7 ≡ 9 (mod 8).
22
5(9) (mod 8), since
Remark 3.1.4. (1) If a · b ≡ 0 (mod n) then it is not necessarily true that
a ≡ 0 (mod n) and b ≡ 0 (mod n). For example 4·3 ≡ 0 (mod 12) but 3 6≡
0 (mod 12) and 4 6≡ 0 (mod 12).
(2) If a · b ≡ 0 (mod n) and gcd(a, n) = 1 then, b ≡ 0 (mod n).
(3) If p is prime and a · b ≡ 0 (mod p) then either a ≡ 0 (mod p) or b ≡
0 (mod p).
3.2
Special divisibility tests
Given an integer b > 1, any positive integer N can be written uniquely in
terms of powers of b as
N = am bm + am−1 bm−1 + · · · + a2 b2 + a1 b + a0 .
Where the coefficient ak can take on the b different values 0, 1, 2, · · · , b − 1.
By division algorithm
N = q1 b + a0 ,
0 ≤ a0 < b.
If q1 ≥ b, we can divide once more, obtaining
q1 = q2 b + a 1 ,
0 ≤ a1 < b1 .
Now substitute for q1 in the earlier equation to get
N = (q2 b + a1 )b + a0 = q2 b2 + a1 b + a0 .
As long as q2 ≥ b, we can continue in the same fashion, going one more step:
q2 = q3 b + a2 , where 0 ≤ a2 < b, we hence
N = q3 b3 + a2 b2 + a1 b + a0 .
Since N > q1 > q2 > · · · ≥ 0 is a strictly decreasing sequence of integers, this
process must eventually terminate say, at the (m-1)th stage, where qm−1 =
qm b + am−1 , 0 ≤ am−1 < b and0 ≤ qm < b. Setting am = qm , we reach the
representation
N = am bm + am−1 bm−1 + · · · + a1 b + a0 .
23
Which was our aim.
The number
N = am bm + am−1 bm−1 + · · · + a1 b + a0
may be replaced by the simpler symbol
N = (am am−1 · · · a2 a1 a0 )b .
We call this the base b place value notation for N .
If b = 2 the resulting system of enumeration is called the binary number
system.
Example 3.2.1. a = 105 can be written in binary system as 105 = 1 · 26 +
1 · 25 + 0 · 24 + 1 · 23 + 0 · 22 + 0 · 2 + 1 = 26 + 25 + 23 + 1. Or in abbreviated
form 105 = (1101001)2 .
And (1001111)2 translates into 1 · 26 + 0 · 25 + 0 · 24 + 1 · 23 + 1 · 22 + 1 · 2 + 1 =
26 + 23 + 22 + 2 + 1 = 79.
decimal system: If the base b = 10 then we can represent any integer
with this base.
Example 3.2.2. a = 1492 = 1 · 103 + 4 · 102 + 9 · 10 + 2.
The integers 1, 4, 9, 2 are called the digits of the given number.
1 is called the thousands digit, 4 the hundreds digits, 9 the tens digit, and 2
the unit digit.
Theorem 3.2.1. Let P (x) =
m
X
ck xk be a polynomial function of x with
k=0
integral coefficients ck . If a ≡ b (mod n), then P (a) ≡ P (b) (mod n).
Proof. Since a ≡ b (mod n) then ak ≡ bk (mod n) for k = 0, 1, 2, · · · , m
therefore ck ak ≡ ck bk (mod n) for all such k. Adding these congruences, we
conclude that
m
k
X
X
k
ck a ≡
ck bk (mod n).
k=0
k=0
or P (a) ≡ P (b) (mod n).
Definition 3.2.1. If P (x) is a polynomial with integral coefficients, one says
that a is a solution of the congruence P (x) ≡ 0 (mod n) if P (a) ≡ 0 (mod n).
24
Corollary 3.2.2. If a is a solution of P (x) ≡ 0 (mod n) and a ≡ b (mod n),
then b is also a solution.
Proof. From previous theorem P (a) ≡ P (b) (mod n). Hence if a is a solution
of P (x) ≡ 0 (mod n), then P (b) ≡ P (a) ≡ (mod n), making b a solution.
Theorem 3.2.3. Let N = am 10m + am−1 10m−1 + · · · a1 10 + a0 , be the decimal
expansion of the positive integer N, 0 ≤ ak < 10, and let S = a0 +a1 +· · ·+am .
Then 9|N if and only if 9|S.
Proof. Consider P (x) =
m
X
ak xk , a polynomial with integral coefficients. 10 ≡
k=0
1 (mod 9) =⇒ P (10) ≡ P (1) (mod 9), but P (10) = N and P (1) = a0 + a1 +
· · · + am = S =⇒ N ≡ S (mod 9). It follows that
N ≡ 0 (mod 9) if and only if S ≡ 0 (mod 9).
Which is the wanted prove.
Theorem 3.2.4. Let N = am 10m + am−1 10m−1 + · · · a1 10 + a0 , be the decimal
expansion of the positive integer N, 0 ≤ ak < 10, and let T = a0 − a1 + a2 −
· · · (±1)m am . Then 11|N if and only if 11|T .
Proof. Put P (x) =
m
X
ak xk . Since 10 ≡ −1 (mod 11), we get P (10) ≡ P (−1) (mod 11).
k=0
But N = P (10), T = P (−1) = a0 −a1 +a2 −· · ·+(±1)m am . So N ≡ T (mod 11),
it follows that N ≡ 0(mod 11) if and only if T ≡ 0 (mod 11).
Example 3.2.3. Let N = 1571724 then 1+5+7+1+7+2+4 = 27 is divisible by 9 =⇒
9|N .
And it divisible by 11 because 4 − 2 + 7 − 1 + 7 − 5 + 1 = 11 is divisible by
11 =⇒ 11|N .
3.3
Linear congruences
Definition 3.3.1. An equation ax ≡ b (mod n) is called a linear congruence
and x0 is a solution of this congruence if ax0 ≡ b (mod n).
Theorem 3.3.1. The linear congruence ax ≡ b (mod n) has a solution if and
only if d|b, where d = gcd(a, n). If d|b, then it has d mutually incongruent
solutions modulo n.
25
Proof. Let ax ≡ b (mod n) has a solution the there exists x0 ∈ Z 3 ax0 ≡
b (mod n) =⇒ n|ax0 − b =⇒ y ∈ Z 3 ax0 − b = ny =⇒ ax0 − ny = b, but this
equation has a solution, then gcd(a, n) = d|b.
Conversely, let d|b and let ax ≡ b (mod n) =⇒ n|ax − b =⇒ ∃y ∈ Z 3 ax − b =
ny =⇒ ax − ny = b,
since gcd(a, n) = d|b =⇒ ax − ny = b has a solution, say x0 , y0 and all
solutions are x = x0 + nd t, y = y0 + ad t, for some choice of t. Then the congruence
ax ≡ b (mod n) has a solution if and only if gcd(a, n) = d|b.
Let now x = x0 + nd t be all solutions for the congruence, where 0 ≤ t ≤ d − 1.
We will show that the solutions
x0 , x 0 +
n
(d − 1)n
, · · · , x0 +
d
d
are not congruent modulo n.
Suppose that x0 + nd t1 ≡ x0 + nd t2 (mod n), where 0 ≤ t1 < t2 ≤ d − 1. We
n
have nd t1 ≡ nd t2 (mod n), but gcd( nd , n) = nd =⇒ t1 ≡ t2 (mod n/d
) =⇒ t1 ≡
t2 (mod d) =⇒ d|t2 − t1 =⇒ d < t2 − t1 , but 0 ≤ t2 − t1 < d, contradiction.
Then x0 + nd t1 6≡ x0 + nd t2 (mod n).
It remains to show that any other solution x0 + ( nd )t is congruent modulo n to
one of the d integers listed above.
By division algorithm t = qd + r where 0 ≤ r ≤ d − 1. Hence
x0 +
n
n
n
n
t = x0 + (qd + r) = x0 + nq + r ≡ x0 + r (mod n),
d
d
d
d
whith x0 + nd r being one of our d selected solutions.
Corollary 3.3.2. If gcd(a, n) = 1, then the linear congruence ax ≡ b (mod n)
has a unique solution modulo n.
Example 3.3.1. Solve the congruence 18x ≡ 30 (mod 42).
Solution gcd(18, 42) = 6 and 6|30 =⇒
the congruence has exactly six solutions which are incongruent modulo 42.
Then
18x ≡ 30 (mod 42)
3x ≡ 5 (mod 7)
6x ≡ 10 (mod 7)
26
−x ≡ 3 (mod 7) =⇒ x ≡ −3 (mod 7)
x ≡ 4 (mod 7) =⇒ x0 = 4.
All solutions of the original congruence are
x = x0 +
42
t = 4 + 7t, 0 ≤ t < 6,
6
which are x = 4, 11, 18, 25, 32, 39 (mod 42).
Example 3.3.2. Solve the congruence
9x ≡ 21 (mod 30).
Solution gcd(9, 30) = 3, 3|21, so the congruence is solvable, then
3x ≡ 7 (mod 10)
21x ≡ 49 (mod 10)
x ≡ 9 (mod 0) =⇒ x0 = 9.
All solutions are x = x0 + t 30
= 9 + 10t for 0 ≤ t < 3.
3
Theorem 3.3.3. (The Chinese Remainder theorem)
Let n1 , n2 , · · · , nr be positive integers such that gcd(ni , nj ) = 1 for i 6= j.
Then the system of linear congruences
x ≡ a1
x ≡ a2
..
.
···
x ≡ ar
(mod n1 )
(mod n2 )
···
(mod nr )
has a common solution which is unique modulo n1 n2 · · · nr .
r
Y
n
for 1 ≤ k ≤ r.
n
k
i=1
Since gcd(ni , nj ) = 1 for i 6= j, then gcd(Nk , nk ) = 1 =⇒
∃ a unique solution xk for the congruence Nk x ≡ 1 (mod nk ) ∀k, 1 ≤ k ≤ r.
=⇒ ak Nk xk ≡ ak (mod nk ) ∀k, 1 ≤ k ≤ r, and ak Nk xk ≡ 0 (mod nj ) for j 6= k.
Let
r
X
x̄ =
ak Nk xk ≡ ak Nk xk (mod nk ).
Proof. Let n =
ni = n1 n2 · · · nr and Nk =
k=1
27
the x̄ is a common solution for the original system of congruences.
But xk was chosen to satisfy the congruence Nk x ≡ 1 (mod nk ), which forces
x̄ ≡ ak · 1 ≡ ak (mod nk ).
This implies that the solution of the given system of congruences exists.
To show uniqueness,
Suppose that x0 is another common solution of the congruences
x ≡ ak (mod nk ), for 1 ≤ k ≤ r.
Then x0 ≡ x̄ (mod nk ) for 1 ≤ k ≤ r.
then lcm(n1 , n2 , · · · nr )|x0 − x̄, but gcd(ni , nj ) = 1 for i 6= j, then n|x0 − x̄ then
x0 ≡ x̄ (mod n).
Example 3.3.3. Find the common solution of the system of congruences
x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7).
Solution
a1 = 2, a2 = 3, a3 = 2 and n1 = 3, n2 = 5, n3 = 7
n = 3 · 5 · 7 = 105.
N1 =
n
n
n
= 35, N2 =
= 21, N3 =
= 15.
n1
n2
n3
The linear congruences
35x ≡ 1 (mod 3), 21x ≡ 1 (mod 5), 15x ≡ 1 (mod 7),
has solutions
x ≡ 2 (mod 3), x ≡ 1 (mod 5), x ≡ 1 (mod 7).
So x1 = 2, x2 = 1, x3 = 1 respectively.
Thus the common solution of the original system is given by
x̄ =
3
X
ak Nk xk = 2 · 35 · 2 + 3 · 21 · 1 + 2 · 15 · 1 = 233 ≡ 23 (mod 105).
k=1
The solution of the congruence ax + by ≡ c (mod n)
The congruence ax + by ≡ c (mod n) has a solution if and only gcd(a, b, n)|c.If
gcd(a, b, n) = 1, then either gcd(a, n) = 1 or gcd(b, n) = 1.
Let gcd(a, b) = 1. The congruence can be written in the form
ax ≡ c − by (mod n).
28
then the congruence has a unique solution x for each of the n incongruent
values of y.
Example 3.3.4. Solve the congruence
7x + 4y ≡ 5 (mod 12),
then 7x ≡ 5 − 4y (mod 12). Substitution of y ≡ 5 (mod 12) then 7x ≡
−15(mod 12). Then
−5x ≡ − 15 (mod 12) =⇒ x ≡ 3(mod 12)
It follows that x ≡ 3 (mod 12) and x ≡ 5(mod 12) is one of the 12 incongruent solutions of
7x + 4y ≡ 5(mod 12).
Theorem 3.3.4. The system of linear congruences
ax + by ≡ r(mod n)..........(1)
cx + dy ≡ s(mod n)..........(2)
has a unique solution modulo n whenever gcd(ad − bc, n) = 1.
Proof. multiply the congruence (1) by d and the congruence (2) by b we get
adx + bdy ≡ rd(mod n)
cbx + dby ≡ sb(mod n).
Now subtract the last equations we get
(ad − cb)x ≡ rd − bs (mod n)............(3).
Since gcd(ad − bc, n) = 1 then the congruence
(ad − bc)z ≡ 1 (mod n)
has a unique solution; denote the solution by t.
Now multiply the congruence (3) by t we obtain
(ad − bc)tx ≡ (dr − bs)t (mod n).
Then
x ≡ (dr − bs)t (mod n).
29
now if we multiply the congruence (1) by c and the congruence (2) by a and
subtract we obtain
(ad − bc)y ≡ (as − cr)(mod n).
now multiply the congruence by t we get
y ≡ t(as − cr)(mod n).
So we have get the solution of the congruence.
Example 3.3.5. Solve the system of congruences
7x + 3y ≡ 10 (mod 16),
2x + 5y ≡ 9 (mod 16)
Solution: Since gcd(7·5−2·3, 16) = 1 so there is a solution of the congruences.
Multiply the first congruence by 5, the second by 3 and subtract we get
29x ≡ 23(mod 16)
then
13x ≡ 7(mod 16),
now multiply by 5 we get
65x ≡ 35 (mod 16) =⇒ x ≡ 3(mod 16).
Now multiply the first congruence by 2 and the second by 7 we get
14x + 6y ≡ 20(mod 16)
14x + 35y ≡ 63(mod 16).
now by subtraction we get
29y ≡ 43(mod 16) =⇒ 13y ≡ 11(mod 16),
multiply by 5 we get 65y ≡ 55(mod 16) =⇒ y ≡ 7(mod 16).
30
Chapter 4
Fermat’s theorem
4.1
Fermat’s little theorem
Theorem 4.1.1. (Fermat’s theorem)
If p is a prime and p - a then ap−1 ≡ 1(mod p).
Proof. Consider the first p − 1 positive multiples of a; that is the integers
a, 2a, 3a, · · · , (p − 1)a.
None of these numbers is congruent modulo p to any other, nor is any congruent to zero, because if ra ≡ sa(mod p), for 1 ≤ r ≤ s ≤ p − 1 and gcd(a, p) =
1 =⇒ r ≡ s(mod p). A contradiction.
Therefore, the above set of integers must be congruent modulo p to 1, 2, 3, · · · , p−
1, taken in some order. multiplying all these congruences together, we find that
a · 2a · 3a · · · (p − 1)a ≡ 1 · 2 · 3 · · · (p − 1)(mod p).
Then
ap−1 (p − 1)! ≡ (p − 1)!(mod p)
but p - (p − 1)! then gcd((p − 1)!, p) = 1 =⇒ ap−1 ≡ 1(mod p).
Corollary 4.1.2. If p is a prime, then ap ≡ a (mod p) for any integer a.
Proof. when p|a then p|ap =⇒ p|ap − a =⇒ ap ≡ a(mod p).
If p - a, then ap−1 ≡ 1(mod p) =⇒ ap ≡ a(mod p).
Theorem 4.1.3. (a + 1)p ≡ ap + 1 ≡ (mod p) ≡ a + 1(mod p).
31
Proof.
Ã
(a+1)p = ap +
p
1
!
Ã
ap−1 +· · ·
p
p−1
!
a+1 ≡ ap +0+· · ·+0+1 (mod p) ≡ a+1 (mod p).
Example 4.1.1. Verify that 538 ≡ 4 (mod 11).
Solution: 538 = 510·3+8 = (510 )3 · (52 )4 since gcd(5, 11) = 1 then 511−1 ≡
1(mod 11) =⇒ 510 ≡ 1(mod 11) =⇒ 538 ≡ 13 · (52 )4 ≡ 1 · 34 ≡ 81 (mod 11) ≡
4 (mod 11).
Note:(1) If n is composite then it is not necessarily true an ≡ a(mod n).
For Example 2117 = 27·16+5 = (27 )16 ·25 (mod 117) and 27 = 128 ≡ 11(mod 117),
we have
2117 ≡ 1116 · 25 (mod 117) ≡ (121)8 · 25 (mod 117) ≡ 48 · 25 (mod 117)
≡ 221 ≡ (27 )3 ≡ (11)3 ≡ 121 · 11 ≡ 4 · 11 ≡ 44(mod 117) 6≡ 2 (mod 117).
The number 117 = 13 · 9 is a composite number.
(2) If an−1 ≡ 1 (mod n) =⇒ n is not necessarily prime.
For example 2341−1 ≡ 1 (mod 341) but 341 = 11 · 31 is not prime.
Lemma 4.1.4. If p and q are distinct primes such that ap ≡ a(mod q) and
aq ≡ a(mod p), then apq ≡ a(mod pq).
Proof. (aq )p ≡ aq (mod p) ∀a ∈ Z. While aq ≡ a (modp) =⇒ apq ≡ a (mod p) or p|apq −
a, also q|apq − a. Since lcm(p, q) = pq|apq − a =⇒ apq ≡ a (mod pq).
Example 4.1.2. Show that 2340 ≡ 1(mod 341), where 341 = 11(31).
Solution:210 = 1024 = 31 · 33 + 1
211 = 2 · 210 ≡ 2 · 1 ≡ 2(mod31) and 231 = 2(210 )3 ≡ 2 · 13 ≡ 2 (mod 11) =⇒
(211 )31 ≡ 2 (mod 11 · 31) =⇒ 2341 ≡ 2(mod 341)
Since gcd(2, 341) = 1 =⇒ 2340 ≡ 1 (mod 341).
4.2
Wilson’s theorem
Theorem 4.2.1. If p is a prime then (p − 1)! ≡ −1(mod p).
32
Proof. If p = 2 or p = 3 then the proof is trivial.
Let p > 3, Suppose that a is any one of the p−1 positive integers 1, 2, 3, · · · , p−
1 and consider the linear congruence ax ≡ 1 (mod p), then gcd(a, p) = 1. So
the congruence ax ≡ 1(mod p) has a unique solution modulo p, ∃a0 ∈ Z with
1 ≤ a0 ≤ p − 1, satisfying aa0 ≡ 1(mod p).
Since p is prime a = a0 if and only if a = 1 or p − 1, because 1 · 1 ≡ 1(mod p)
and (p − 1)2 ≡ 1(mod p). Or the congruence a2 ≡ 1(mod p) is equivalent to
(a − 1)(a + 1) ≡ 0(mod p), then either
(a − 1) ≡ 0(mod p) or a + 1 ≡ 0(mod p) then a ≡ 1(mod p) =⇒ a = 1 or
a + 1 = p =⇒ a = p − 1.
If we omit the numbers 1 and p−1, the effect is to group the remaining integers
2, 3, · · · , p − 2 into pairs a, a0 , where a 6= a0 ; Such that aa0 ≡ 1(mod p). When
these p−3
congruences are multiplied together and the factors rearranged we get
2
2 · 3 · · · (p − 2) ≡ 1(mod p)
or
(p − 2)! ≡ 1(mod p)
then
(p − 1)(p − 2)! ≡ (p − 1) ≡ −1(mod p)
which implies that (p − 1)! ≡ −1(mod p).
Example 4.2.1. Verify Wilson’s theorem for p = 13.
Solution:We divide the integers 2, 3, · · · 11 into p−3
= 5 pairs each of whose
2
products is congruent to 1 modulo 13. Now write out these congruences explicitly we get
2 · 7 ≡ 1(mod 13)
3 · 9 ≡ 1(mod 13)
4 · 10 ≡ 1(mod 13) .
5 · 8 ≡ 1(mod 13)
6 · 11 ≡ 1(mod 13)
Multiply the above congruence gives the result
11! = (2·7)(3·9)(4·10)(5·8)(6·11) ≡ 1(mod13). =⇒ 12! ≡ 12 ≡ −1(mod 13) =⇒
(p − 1)! ≡ −1(mod p) with p = 13.
Note:The converse of Wilson’s theorem is also true If (n − 1)! ≡ −1(mod n),
then n must be prime.
33
To prove this: let n be not prime, then n has a divisor d, with 1 < d < n.
Furthermore, since d ≤ n − 1, d occurs as one of the factors in (n − 1)!, whence
d|(n − 1)!, Now we are assuming that n|(n − 1)! + 1 and so d|(n − 1)! + 1 too,
then d|1 which is a contradiction. So n is prime.
Theorem 4.2.2. The quadratic congruence x2 + 1 ≡ 0(mod p), where p is an
odd prime, has a solution if and only if p ≡ 1(mod 4).
Proof. Let a be any solution of x2 + 1 ≡ 0(mod p), so that a2 ≡ −1(mod p).
Since p - a, the outcome of applying Fermat’s Theorem is
1 = ap−1 ≡ (a2 )
p−1
2
≡ (−1)
p−1
2
(mod p).
The possibility that p = 4k + 3 for k ∈ Z is not arise because
p−1
(−1) 2 = (−1)2k+1 = −1 =⇒ 1 ≡ −1(mod p) =⇒ p|2 which false. Therefore
p−1
p = 4k + 1 because (−1) 2 = (−1)2k = 1 =⇒ 1 ≡ 1(mod p), so p ≡ 1(mod 4).
Conversely, Let p ≡ 1(mod 4). By Wilson’s theorem, we have (p − 1)! =
1 · 2 · · · ( p−1
) · ( p+1
) · · · (p − 2)(p − 1), also
2
2
p − 1 ≡ −1(mod p),
p − 2 ≡ −2(mod p)
..
.
p+1
p−1
≡ −(
)(mod p).
2
2
Rearranging the factor produces,
(p − 1)! ≡ 1 · (−1) · (2) · (−2) · · · (
p−1
p−1
)(−
)(mod p),
2
2
then
p−1 2
)) (mod p).
2
If p ≡ 1(mod 4) =⇒ p = 4k + 1, then − 1 ≡ (( p−1
)!)2 (mod p).
2
The conclusion ( p−1
)! satisfies the quadratic congruence x2 +1 ≡ 0(mod p).
2
(p − 1)! ≡ (−1)
p−1
2
(1 · 2 · · · (
Example 4.2.2. Solve the congruence x2 + 1 ≡ 0(nod 13).
Solution: Since p = 13 and 13 ≡ 1(mod 4) then the congruence has a solution,
so x = ( p−1
)! = 6! = 720 ≡ 5(mod 13) is a solution.
2
34
© Copyright 2026 Paperzz