Number Theory Updated
Number Theory Updated
5
gers qi, ri ∈ N such that
b = q0 a + r 0 , 0 ≤ r0 < a,
a = q1 r 0 + r 1 , 0 ≤ r1 < r0 ,
r0 = q2 r 1 + r 2 , 0 ≤ r2 < r1 ,
r1 = q3 r 2 + r 3 , 0 ≤ r3 < r2 ,
..
rk−2 = qk rk−1 + rk , 0 ≤ rk < rk−1,
rk−1 = qk+1rk + rk+1, rk+1 = 0.
The nonnegative sequence {ri} is strictly decreasing. It
must end to 0 at some step, say, rk+1 = 0 for the very first
time. Then ri 6= 0, 0 ≤ i ≤ k. Reverse the sequence {ri}ki=0
and make substitutions as follows:
d = rk ,
rk = rk−2 − qk rk−1,
rk−1 = rk−3 − qk−1rk−2,
..
r 1 = a − q1 r 0 ,
r0 = b − q0a.
We see that gcd(a, b) can be expressed as an integral linear
combination of a and b. This procedure is known as the Eu-
clidean Algorithm.
We summarize the above argument into the following the-
orem.
Theorem 2.3. For any integers a, b ∈ Z, there exist in-
6
tegers x, y ∈ Z such that
gcd(a, b) = ax + by.
Example 2.2. Express gcd(297, 3627) as an integral linear
combination of 297 and 3627.
Dy the Division Algorithm, we have gcd(297, 3627) = 9.
By the Euclidean Algorithm,
9 = 45 − 2 · 18
= 45 − 2(63 − 45)
= 3 · 45 − 2 · 63
= 3(297 − 4 · 63) − 2 · 63
= 3 · 297 − 14 · 63
= 3 · 297 − 14(3627 − 12 · 297)
= 171 · 297 − 14 · 3627.
Example 2.3. Find gcd(119, 45) and express it as an integral
linear combination of 45 and 119.
Applying the Division Algorithm,
119 = 2 · 45 + 29
45 = 29 + 16
29 = 16 + 13
16 = 13 + 3
13 =4·3+1
7
So gcd(119, 45) = 1. Applying the Euclidean Algorithm,
1 = 13 − 4 · 3 = 13 − 4(16 − 13)
= 5 · 13 − 4 · 16 = 5(29 − 16) − 4 · 16
= 5 · 29 − 9 · 16 = 5 · 29 − 9(45 − 29)
= 14 · 29 − 9 · 45 = 14(119 − 2 · 45) − 9 · 45
= 14 · 119 − 37 · 45
Example 2.4. Find gcd(119, −45) and express it as linear
combination of 119 and -45.
We have gcd(119, −45) = gcd(119, 45) = 1. Since
1 = 14 · 119 − 37 · 45,
we have gcd(119, −45) = 14 · 119 + 37 · (−45).
8
Theorem 2.5 (Unique Factorization). Every integer
a ≥ 2 can be uniquely factorized into the form
a = pe11 pe22 · · · pemm ,
where p1, p2, . . . , pm are distinct primes, e1, e2, . . . , em are
positive integers, and p1 < p2 < · · · < ps.
Proof. (Not required) We first show that a has a factorization
into primes. If a has only the trivial divisors, then a itself is
a prime, and it obviously has unique factorization. If a has
some nontrivial divisors, then
a = bc
for some positive integers b, c ∈ P other than 1 and a. So
b < a, c < a. By induction, the positive integers b and c have
factorizations into primes. Consequently, a has a factorization
into primes.
Next we show that the factorization of a is unique in the
sense of the theorem.
Let a = q1f1 q2f2 · · · afnn be any factorization, where q1, q2, . . . , qn
are distinct primes, f1, f2, . . . , fn are positive integers, and
q1 < q2 < · · · < qn. We claim that m = n, pi = qi, ei = fi
for all 1 ≤ i ≤ m.
Suppose p1 < q1. Then p1 is distinct from the primes
q1, q2, . . . , qn. It is clear that gcd(p1, qi) = 1, and so
gcd(p1, qifi ) = 1 for all 1 ≤ i ≤ n.
9
Note that p1 | q1f1 q2f2 · · · afnn . Since gcd(p1, q1f1 ) = 1, by Propo-
sition 2.4, we have p1 | q2f2 · · · afnn . Since gcd(p1, q2f2 ) = 1,
again by Proposition 2.4, we have p1 | q3f2 · · · afnn . Repeating
the argument, eventually we have p1 | qnfn , which is contrary
to gcd(p1, qnfn ) = 1. We thus conclude p1 ≥ q1. Similarly,
q1 ≥ p1. Therefore p1 = q1. Next we claim e1 = f1.
Suppose e1 < f1. Then
pe22 · · · pemm = pf11−e1 q2f2 · · · qnfn .
This implies that p1|pe22 · · · pemm . If m = 1, then pe22 · · · pemm =
1. So p1 | 1. This is impossible because p1 is a prime. If
m ≥ 2, since gcd(p1, pi) = 1, we have gcd(p1, pei i ) = 1 for
all 2 ≤ i ≤ m. Applying Proposition 2.4 repeatedly, we
have p1|pemm , which is contrary to gcd(p1, pemm ) = 1. We thus
conclude e1 ≥ f1. Similarly, f1 ≥ e1. Therefore e1 = f1.
Now we have obtained pe22 · · · pemm = q2f2 · · · qnfn . If m < n,
then by induction we have p1 = q1, . . . , pm = qm and e1 =
fm+1
f1, . . . , em = fm. Thus 1 = qm+1 · · · qnfn . This is impossible
because qm+1, . . . , qn are primes. So m ≥ n. Similarly, n ≥
m. Hence we have m = n. By induction, we have e2 =
f2, . . . , em = fm.
Our proof is finished.
Example 2.5. Factorize the numbers 180 and 882, and find
gcd(180, 882).
Solution. 180/2=90, 90/2=45, 45/3=15, 15/3=5, 5/5=1.
Then 360 = 22 · 32 · 5. Similarly, 882/2=441, 441/3=147,
10
147/3=49, 49/7=7, 7/7=1. We have 882 = 2 · 32 · 72. Thus
gcd(180, 882) = 2 · 32 = 18.
4 Solving ax + by = c
12
By inspection, (x, y) = (−5, 2) is a solution for the equation
25x + 65y = 5.
Since 10
5 = 2, then (x, y) = 2(−5, 2) = (−10, 4) is a solution
for 25x + 65y = 10.
Example 4.2. Find an integer solution for the equation
25x + 65y = 18.
Solution. Since gcd(25, 65) = 5, if the equation has a solu-
tion, then 5 | (25x + 65y). So 5 | 18 by Proposition 1.2 (c).
This is a contradiction. Hence the equation has no solution.
Theorem 4.1. The linear Diophantine equation
ax + by = c,
has a solution if and only if gcd(a, b) | c.
Theorem 4.2. Let S be the set of solutions of the equation
ax + by = c. (1)
Let S0 be the set of solutions of the homogeneous equation
ax + by = 0. (2)
If (x, y) = (u0, v0) is a solution of (2), then S is given by
S = {(u0 + s, v0 + t) : (s, t) ∈ S0}.
In other words, all solutions of (1) are given by
½
x = u0 + s
, (s, t) ∈ S0. (3)
y = v0 + t
13
Proof. Since (x, y) = (u0, v0) is a solution of (1), then au0 +
bv0 = c. For any solution (x, y) = (s, t) of (2), we have
as + bt = 0. Thus
a(u0 + s) + b(v0 + t) = (au0 + bv0) + (as + bt) = c.
This means that (x, y) = (u0 + s, v0 + t) is a solution of (1).
Conversely, for any solution (x, y) = (u, v) of (1), we have
au + bv = c. Let (s0, t0) = (u − u0, v − v0). Then
as0 + bt0 = a(u − u0) + b(v − v0)
= (au + bv) − (au0 + bv0)
= c − c = 0.
This means that (s0, t0) is a solution of (2). Note that
(u, v) = (u0 + s0, v0 + t0).
This shows that the solution (x, y) = (u, v) is a solution of
the form in (3). Our proof is finished.
Theorem 4.3. Let d = gcd(a, b). The solution set S0 of
ax + by = 0
is given by
½ µ ¶ ¾
b a
S0 = k ,− :k∈Z .
d d
In other words,
½
x = (b/d)k
, k ∈ Z.
y = −(a/d)k
14
Proof. The equation ax + by = 0 can be written as
ax = −by.
Write m = ax = −by. Then a | m and b | m, i.e., m is a
multiple of a and b. Thus m = k · lcm(a, b) for some k ∈ Z.
Therefore ax = k · lcm(a, b) implies
k · lcm(a, b) kab kb
x= = = .
a da d
Similarly, −by = k · lcm(a, b) implies
k · lcm(a, b) kab ka
y= = =− .
−b −db d
15
Solution. Find gcd(25, 65) = 5 and have got a special solu-
tion (x, y) = (−10, 4) in a previous example. Now consider
the equation 25x + 65y = 0. Divide both sides by 5 to have,
5x + 13y = 0.
Since gcd(5, 13) = 1, all solutions for the above equation are
given by (x, y) = k(−13, 5), k ∈ Z. Thus all solutions of
25x + 65y = 10 are given by
½
x = −10 − 13k
, k ∈ Z.
y = 4 + 5k
16
Example 4.4.
168x + 668y = 888.
Solution. Find gcd(168, 668) = 4 by the Division Algorithm
668 = 3 · 168 + 164
168 = 164 + 4
164 = 41 · 4
By the Euclidean Algorithm,
4 = 168 − 164
= 168 − (668 − 3 · 168)
= 4 · 168 + (−1) · 668.
888
Dividing 4 = 222, we obtain a special solution
(x, y) = 222(4, −1) = (888, −222)
Solve 168x + 668y = 0. Dividing both sides by 4,
42x + 167y = 0 i.e. 42x = −167y.
The general solutions for 168x + 668y = 0 are given by
(x, y) = k(167, −42), k ∈ Z.
The general solutions for 168x + 668y = 888 are given by
(x, y) = (888, −222) + k(167, −42), k ∈ Z.
½
x = 888 +167k
i.e. , k ∈ Z.
y = −222 −42k
17
5 Modulo Integers
Example 5.1.
3 ≡ 5 (mod 2), 368 ≡ 168 (mod 8),
−8 ≡ 10 (mod 9), 3 6≡ 5 (mod 3),
368 6≡ 268 (mod 8), −8 6≡ 18 (mod 9).
Proposition 5.1. Let n be a fixed positive integer. If
a1 ≡ b1 (mod n), a2 ≡ b2 (mod n),
then
a1 + a2 ≡ b1 + b2 (mod n),
a1 − a2 ≡ b1 − b2 (mod n),
18
a1a2 ≡ b1b2 (mod n).
If a ≡ b (mod n), d | n, then
a ≡ b (mod d).
Proof. Since a1 ≡ b1 (mod n), a2 ≡ b2 (mod n), there are
integers k1, k2 such that
b1 − a1 = k1n, b2 − a2 = k2n.
Then
(b1 + b2) − (a1 + a2) = (k1 + k2)n;
(b2 − b1) − (a1 − a2) = (k1 − k2)n;
19
Example 5.2.
6 ≡ 14 (mod 8) =⇒ 2 · 6 ≡ 2 · 14 (mod 8);
µ ¶
6 14 8
6 ≡ 14 (mod 8) ⇐⇒ ≡ mod ;
2 2 2
However,
2 · 3 ≡ 2 · 7 (mod 8) =⇒
6 3 ≡ 7 (mod 8).
In fact,
3 6≡ 7 (mod 8).
Theorem 5.2. Let c | a, c | b, and c | n. Then
a b ³ n´
a ≡ b (mod n) ⇐⇒ ≡ mod .
c c c
Proof. Write a = ca1, b = cb1, n = cn1. Then
a ≡ b (mod n) ⇐⇒ b − a = kn for an integer k
⇐⇒ c(b1 − a1) = kcn1
⇐⇒ b/c − a/c = b1 − a1 = kn1
⇐⇒ a/c ≡ b/c (mod n/c).
Theorem 5.3.
a ≡ b (mod m), a ≡ b (mod n),
⇐⇒
a ≡ b (mod lcm(m, n)).
In particular,
gcd(m, n) = 1 ⇐⇒ a ≡ b (mod mn).
20
Proof. Write l = lcm(m, n). If a ≡ b (mod m), a ≡ b (mod n),
then m | (b − a) and n | (b − a). Thus l | (b − a), i.e.,
a ≡ b (mod l).
Conversely, if a ≡ b (mod l), then l | (b − a). Since m | l,
n | l, we have m | (b − a), n | (b − a). Thus a ≡ b (mod m),
a ≡ b (mod n).
In particular, if gcd(m, n) = 1, then l = mn.
Definition 5.4. An integer a is called invertible modulo
n if there exists an integer b such that
ab ≡ 1 (mod n).
If so, b is called the inverse of a modulo n.
Proposition 5.5. An integer a is invertible modulo n if
and only if gcd(a, n) = 1
Proof. “⇒”: If a is invertible modulo n, say its inverse is b,
then exists an integer k such that ab = 1 + kn, i.e.,
1 = ab − kn.
Thus gcd(a, n) divides 1. Hence gcd(a, n) = 1.
“⇐”: By the Euclidean Algorithm, there exist integers u, v
such that 1 = au + nv. Then au ≡ 1 (mod n).
Example 5.3. The invertible integers modulo 12 are the
following numbers
1, 5, 7, 11.
Numbers 0, 2, 3, 4, 6, 8, 9, 10 are not invertible modulo 12.
21
Theorem 5.6. Let gcd(c, n) = 1. Then
a ≡ b (mod n) ⇐⇒ ca ≡ cb (mod n)
Proof. By the Euclidean Algorithm, there are integers u, v
such that
1 = cu + nv.
Then 1 ≡ cu (mod n); i.e., a and u are inverses of each other
modulo n
“⇒”: c ≡ c (mod n) and a ≡ b (mod n) imply
ca ≡ cb (mod n).
This true without gcd(c, n) = 1.
“⇐”: ca ≡ cb (mod n) and u ≡ u (mod n) imply that
uca ≡ ucb (mod n).
Replace uc = 1 − vn; we have a − avn ≡ b − bvn (mod n).
This means a ≡ b (mod n).
Example 5.4. Find the inverse modulo 15 for each of the
numbers 2, 4, 7, 8, 11, 13.
Solution. Since 2 · 8 ≡ 1 (mod 15), 4 · 4 ≡ 1 (mod 15). Then
2 and 8 are inverses of each other; 4 is the inverse of itself.
Write 15 = 2 · 7 + 1. Then 15 − 2 · 7 = 1. Thus −2 · 7 ≡
1 (mod 15). The inverse of 7 is -2. Since −2 ≡ 13 (mod 15),
the inverse of 7 is also 13. In fact,
7 · 13 ≡ 1 (mod 15).
22
Similarly, 15 = 11 + 4, 11 = 2 · 4 + 3, 4 = 3 + 1, then
1 = 4 − 3 = 4 − (11 − 2 · 4)
= 3 · 4 − 11 = 3 · (15 − 11) − 11
= 15 − 4 · 11.
Thus the inverse of 11 is −4. Since −4 ≡ 11 (mod 15), the
inverse of 11 is also itself, i.e., 11 · 11 ≡ 1 (mod 15).
6 Solving ax ≡ b (mod n)
8 Important Facts
33