Richard Hennigan

advertisement
Proofs, Exercises, and other homework from MAT306
Richard Hennigan
Spring 2012
NumberTheory
II
N UMBER T HEORY
P ROOFS AND H OMEWORK
CONTENTS
1
Divide and Conquer
1.1 Axioms for Integers . . . . . . . . . . . . . . . . . . . . . . .
1.2 Divisibility and Congruence . . . . . . . . . . . . . . . . . .
1.3 The Division Algorithm . . . . . . . . . . . . . . . . . . . . .
1.4 Greatest Common Divisors and Linear Diophantine Equations
.
.
.
.
1
1
1
17
20
2
Prime Time
2.1 The Fundamental Theorem of Arithmetic . . . . . . . . . . . . . . . . . . . .
2.2 Applications of the Fundamental Theorem of Arithmetic . . . . . . . . . . . .
25
25
27
3
A Modular World
3.1 Powers and Polynomials Modulo n . . . . . . . . . . . . . . . . . . . . . . . .
35
35
4
Fermat’s Little Theorem and Euler’s Theorem
4.1 Orders of an integer modulo n . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Fermat’s Little Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3 Euler’s Theorem and Wilson’s Theorem . . . . . . . . . . . . . . . . . . . . .
41
41
43
43
A The Final Project
A.1 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.3 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
45
45
46
46
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
IV
N UMBER T HEORY
CONTENTS
P ROOFS AND H OMEWORK
CHAPTER 1
DIVIDE AND CONQUER
1.1
A XIOMS
FOR I NTEGERS
1 Axiom Closure: If x, y ∈ Z then x + y ∈ Z and xy ∈ Z
∗
2 Axiom Commutative Laws: If x, y ∈ Z then x + y = y + x and xy = yx.
∗
3 Axiom Associative Laws: If x, y, z ∈ Z then (x + y) + z = x + (y + z) and (xy) z = x (yz).
∗
4 Axiom Distributive Laws: If x, y, z ∈ Z, then x (y + z) = xy + xz.
∗
5 Axiom Identity Elements: If x ∈ Z,then x + 0 = x and x · 1 = x, so 0 is the additive identity
and 1 is the multiplicative identity.
∗
6 Axiom Additive Inverse: If x ∈ Z, then −x is the additive inverse: x − x = 0 and −x + x = 0.∗
7 Axiom Cancellation Law for Multiplication: If x, y, z ∈ Z and x · y = x · z, then y = z.
1.2
D IVISIBILITY
AND
∗
C ONGRUENCE
Theorem 1.1 Let a, b, and c be integers. If a|b and a|c, then a| (b + c).
Proof. Since a|b, there exists some integer k1 such that b = ak1 . Similarly, since a|c there is
some integer k2 such that c = ak2 . We wish to show that a| (b + c).We can then write
b
= ak1
2
C HAPTER 1. D IVIDE AND C ONQUER
and
c
= ak2
We can then write
b + c = ak1 + ak2
= a (k1 + k2 ) ,
and since integers are closed under addition, there is some k3 ∈ Z such that k1 + k2 = k3 . So by
substitution we then write
b + c = ak3 ,
which means that a divides b + c and proves our theorem.
Theorem 1.2 Let a, b, and c be integers. If a|b and a|c, then a| (b − c).
Proof. By definition, we have b = ax and c = ay where x, y ∈ Z. Then
b − c = ax − ay,
and using the distributive law, we can write
b − c = a (x − y).
But x − y is an integer, so by definition, this means that a| (b − c).
Theorem 1.3 Let a, b and c be integers. If a|b and a|c, then a|bc.
Proof. We have b = ax and c = ay where x, y ∈ Z. Then
bc = ax · ay
and by associativity
bc = a (xay) .
Since xay ∈ Z, we conclude that a|bc.
N UMBER T HEORY
P ROOFS AND H OMEWORK
3
1.2. D IVISIBILITY AND C ONGRUENCE
Question 1.4 Can you weaken the hypothesis of the previous theorem and still prove the
conclusion? Can you keep the same hypothesis, but replace the conclusion by the stronger
conclusion that a2 |bc and still prove the theorem?
Question 1.5 Can you formulate you own conjecture along the lines of the above theorems
and then prove it to make it your theorem?
Theorem 1.6 Let a, b and c be integers. If a|b, then a|bc.
Proof. Since a | b, ∃m ∈ Z such that b = am. Then bc = amc and since mc ∈ Z, we conclude
that a|bc.
Exercise 1.7 Answer each of the following questions, and prove that your answer is correct.
1. Is 45 ≡ 9 (mod 4)?
Yes, 45 − 9 = 4 · 9.
2. Is 37 ≡ 2 (mod 5)?
Yes, 37 − 2 = 5 · 7.
3. Is 37 ≡ 3 (mod 5)?
No.
Proof. Suppose 37 ≡ 3 (mod 5). Then ∃x ∈ Z,
37 − 3 =
34 =
34
=
5
but
34
5
6∈ Z. Therefore 37 6≡ 3 (mod 5).
MAT-306—S PRING 2012
5x
5x
x,
R ICHARD H ENNIGAN
4
C HAPTER 1. D IVIDE AND C ONQUER
4. Is 37 ≡ −3 (mod 5)?
Yes. 37 − (−3) = 5 · 8.
Exercise 1.8 For each of the following congruences, characterize all the integers m that
satisfy that congruence.
1. m ≡ 0 (mod 3) .
{3x | x ∈ Z} = {. . . , −6, −3, 0, 3, 6, . . .}
2. m ≡ 1 (mod 3) .
{3x + 1 | x ∈ Z} = {. . . , −5, −2, 1, 4, 7, . . .}
3. m ≡ 2 (mod 3) .
{3x + 2 | x ∈ Z} = {. . . , −4, −1, 2, 5, 8, . . .}
4. m ≡ 3 (mod 3) .
{3x | x ∈ Z} = {. . . , −6, −3, 0, 3, 6, . . .}
5. m ≡ 4 (mod 3) .
{3x + 1 | x ∈ Z} = {. . . , −5, −2, 1, 4, 7, . . .}
Theorem 1.9 Let a and n be integers with n > 0. Then a ≡ a (mod n) .
Proof. If a ∈ Z, a − a = 0. Also, n ·0 = 0. Therefore a − a = n0 which implies a ≡ a (mod n) . Theorem 1.10 Let a, b and n be integers with n > 0. If a ≡ b (mod n), then b ≡ a (mod n) .
Let a, b and n be integers with n > 0 and assume a ≡ b (mod n). By definition of
congruence, we have n | a − b, which implies that there exists an integer x such that a − b = nx.
Then we write,
Proof.
a − b = nx
a = nx + b
a − nx = b
−nx = b − a.
N UMBER T HEORY
P ROOFS AND H OMEWORK
5
1.2. D IVISIBILITY AND C ONGRUENCE
Now since x is an integer, we know that −x is also an integer, which we’ll denote y. We can
then write
−nx =
n (−x) =
ny =
b−a
b−a
b − a,
which means that n divides b − a, and therefore we conclude that b ≡ a (mod n) .
Theorem 1.11 Let a, b, c, and n be integers with n > 0. If a ≡ b (mod n) and b ≡ c (mod n) ,
then a ≡ c (mod n) .
Proof. Let a, b, c, and n be integers with n > 0 such that a ≡ b (mod n) and b ≡ c (mod n). By
definition of congruence we have
a − b = nx
and
b − c = ny.
If we then solve for a, b, c, we havea = nx + b, b = ny + c, andc = b − ny. We can then write
a − c = nx + b − (b − ny)
= nx + b − b + ny
= nx + ny
= n (x + y).
Next, let z ∈ Z such that x + y = z. Then
a − c = nz,
which means that a ≡ c (mod n) .
Theorem 1.12 Let a, b, c, d, and n be integers with n > 0.
c ≡ d (mod n) , then a + c ≡ b + d (mod n) .
if a ≡ b (mod n) and
Proof. Let a, b, c, d, and n be integers such that n > 0, a ≡ b (mod n), and c ≡ d (mod n). By
definition of congruence, we have a − b = nx and c − d = ny. Solving for each variable, we have
a = nx + b,
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
6
C HAPTER 1. D IVIDE AND C ONQUER
c = ny + d.
Then
a+c =
a+c−b−d =
nx + b + ny + d
nx + ny.
Now, let z ∈ Z such that x + y = z. Then
a+c−b−d =
a + c − (b + d) =
n (x + y)
nz,
which means that a + c ≡ b + d (mod n) .
Theorem 1.13 Let a, b, c, d, and n be integers with n > 0.
c ≡ d (mod n), then a − c ≡ b − d (mod n) .
If a ≡ b (mod n) and
Proof. Let a, b, c, d, and n be integers such that n > 0, a ≡ b (mod n) and c ≡ d (mod n) . Then
a − b = nx
a
= nx + b,
and
c−d =
c =
ny
ny + d,
where x, y ∈ Z. Then
a − c = nx + b − ny − d
a − c − b + d = nx − ny
a − c − (b − d) = n (x − y).
Now, since x and y are both integers, we know that x − y is also an integer. So let z ∈ Z such
that x − y = z. Then
a − c − (b − d) = nz,
which means that
a − c ≡ b − d (mod n) .
N UMBER T HEORY
P ROOFS AND H OMEWORK
7
1.2. D IVISIBILITY AND C ONGRUENCE
Theorem 1.14 Let a, b, c, d, and n be integers with n > 0.
c ≡ d (mod n), then ac ≡ bd (mod n).
If a ≡ b (mod n) and
Proof. Let a, b, c, d, and n be integers such that n > 0, a ≡ b (mod n) and c ≡ d (mod n). By
definition of congruence, we then have integers x, y such that
a − b = nx,
and
c − d = ny.
We then solve for a and c to obtain
a = nx + b,
and
c = ny + d.
By multiplying these together, we then have
ac
= (nx + b)(ny + d)
= nxny + nxd + nyb + bd.
Then working towards the desired conclusion, we subtract bd to obtain
ac − bd = nxny + nxd + nyb.
Now we have that every term on the right side of the equation has n in it, so we factor to obtain
ac − bd = n (xny + xd + yb).
Now, since integers are closed under addition and multiplication, we know there exists some
integer z such that
z = xny + xd + yb.
By substitution, we then write
ac − bd = nz,
which means that
ac ≡ bd (mod n) ,
which proves our theorem.
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
8
C HAPTER 1. D IVIDE AND C ONQUER
Exercise 1.15 Let a, b, and n be integers with n > 0. Show that if a ≡ b (mod n) , then
a2 ≡ b2 (mod n) .
Proof. Let a, b, and n be integers such that n > 0 and a ≡ b (mod n). By definition of congru-
ence, we have
a − b = nx,
where x ∈ Z. We then solve for a to obtain
a = nx + b,
and then square a, which gives us
a2
= (nx + b)(nx + b)
= n2 x2 + 2bnx + b2.
We then write
a2 − b2
= n2 x2 + 2bnx
= n nx2 + 2bx .
Now, since integers are closed under addition and multiplication, we know there exists some
z ∈ Z such that
z = nx2 + 2bx.
We then substitute to find
a2 − b2 = nz,
which means that
a2 ≡ b2 (mod n) ,
which proves our theorem.
Exercise 1.16 Let a, b, and n be integers with n > 0.
a3 ≡ b3 (mod n) .
If a ≡ b (mod n), then
Proof. Let a, b, and n be integers such that n > 0 and a ≡ b (mod n) . By definition of congruence, there exists an integer x such that
a − b = nx.
N UMBER T HEORY
P ROOFS AND H OMEWORK
9
1.2. D IVISIBILITY AND C ONGRUENCE
If we solve for a, we obtain
a = nx + b,
which we can then cube to write
a3
= (nx + b)(nx + b)(nx + b)
= n2 x2 + 2bnx + b2 (nx + b)
= n3 x3 + 2bn2x2 + b2 nx + bn2x2 + 2b2nx + b3.
Subtracting b3 from both sides gives us
a3 − b3 = n3 x3 + 2bn2x2 + b2nx + bn2x2 + 2b2nx,
which we can then factor to write
a3 − b3 = n n2 x3 + 2bnx2 + b2x + bnx2 + 2b2x .
Now, since the integers are closed under multiplication and addition, we know there exists some
z ∈ Z such that
z = n2 x3 + 2bnx2 + b2x + bnx2 + 2b2x,
which we substitute to obtain
a3 − b3 = nz.
Then, by definition of congruence, we find that
a3 ≡ b3 (mod n) ,
which proves our theorem.
Exercise 1.17 Let a, b, k, and n be integers with n > 0 and k > 0. If a ≡ b (mod n) and
ak−1 ≡ bk−1 (mod n) then ak ≡ bk (mod n) .
Proof. Let a, b, k, and n be integers such that n > 0, k > 0, a ≡ b (mod n) , and ak−1 ≡ bk−1 (mod n) .
By definition of congruence, we have
a−b =
a =
nx
nx + b
and
ak−1 − bk−1 = ny
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
10
C HAPTER 1. D IVIDE AND C ONQUER
where x, y ∈ Z. We then find
ak−1
=
a · ak−1
=
ny + bk−1
a ny + bk−1
ak
=
any + abk−1
ak
ak
=
=
ak − bk
=
any + (nx + b)bk−1
any + nxbk−1 + bk
n ay + xbk−1 .
Since integers are closed under addition and multiplication. There exists z ∈ Z such that
z = ay + xbk−1.
Then
and therefore ak ≡ bk (mod n) .
ak − bk = nz
Theorem 1.18 Let a, b, k, and n be integers with n > 0 and k > 0. If a ≡ b (mod n) , then
ak ≡ bk (mod n) .
Let a, b, k, and n be integers such that n > 0, k > 0, and a ≡ b (mod n) . Then by
definition of congruence, we have
a − b = nx,
Proof.
where x ∈ Z. We then solve for a to obtain
a = nx + b.
We wish to set up an induction proof by using k = 1 as our base case. Since we have
a ≡ b (mod n) ,
we know that
a1 ≡ b1 (mod n) ,
which establishes our base case. For the inductive step, we assume that for some k, we have
ak ≡ bk (mod n) ,
N UMBER T HEORY
P ROOFS AND H OMEWORK
11
1.2. D IVISIBILITY AND C ONGRUENCE
and we wish to show that
ak+1 ≡ bk+1 (mod n) ,
or equivalently,
ak+1 − bk+1 = nz,
where z is some integer.
Now, since
ak ≡ bk (mod n) ,
we can say there exists some integer x such that
ak − bk = nx.
We can then solve for ak to obtain
ak = nx + bk .
Now, if we multiply ak and a, we have
ak · a =
ak+1
ak+1 − bk+1
nx + bk (nx + b)
= nxny + nxbk + nyb + bk+1
= n xny + xbk + yb .
Since integers are closed under addition and multiplication, we know that there exists some
z ∈ Z such that
z = xny + xbk + yb.
We then substitute to obtain
ak+1 − bk+1 = nz,
which means that
ak+1 ≡ bk+1 (mod n) ,
which completes the inductive step, and thus proves our theorem.
Exercise 1.19 Illustrate each of Theorems 1.12–1.18 with an example using actual numbers.
1.12. We wish to show an example of numbers which satisfy a ≡ b (mod n) and c ≡ d (mod n),
will also satisfy a + c ≡ b + d (mod n) . So let n = 3, a = 1, b = 4, c = 2, d = 5. By
definition of congruence, we know there exist integers x and y such that
a − b = nx
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
12
C HAPTER 1. D IVIDE AND C ONQUER
and
c − d = ny.
By substitution, we obtain
1 − 4 = 3x
−3
−1
= 3x
= x
and
2 − 5 = 3y
−3 = 3y
−1 = y.
Since −1 is an integer, our hypothesis is true. We then check the existence of an integer
z in order to test the conclusion as follows.
a+c−b−d =
1+2−4−5 =
−6 =
−2 =
3z
3z
3z
z.
Since −2 is an integer, we have a working example.
1.13. We wish to show an example of numbers which satisfy a ≡ b (mod n) and c ≡ d (mod n),
will also satisfy a − c ≡ b − d (mod n) . We’ll use the same values for a, b, c, and d as the
previous example for our hypothesis. We then check the existence of an integer z in order
to test the conclusion as follows.
a−c−b+d =
1−2−4+5 =
0
0
=
=
nz
3z
3z
z.
Since 0 is an integer, we have a working example.
1.14. We wish to show an example of numbers which satisfy a ≡ b (mod n) and c ≡ d (mod n),
will also satisfy ac ≡ bd (mod n) . We’ll use the same values for a, b, c, and d as the
previous example for our hypothesis. We then check the existence of an integer z in order
N UMBER T HEORY
P ROOFS AND H OMEWORK
13
1.2. D IVISIBILITY AND C ONGRUENCE
to test the conclusion as follows.
ac − bd
=
nz
1·2−4·5 =
−18 =
3z
3z
−6 =
z.
Since −6 is an integer, we have a working example.
1.15. Let a = 1 and b = 4 with n = 3. Then
a ≡ b (mod n)
a − b = nx
1 − 4 = 3x
−1 = x.
Then the conclusion evaluates as
a2
a2 − b2
12 − 42
≡
b2 (mod n)
=
=
ny
3y
−15 =
−5 =
3y
y,
and y is an integer.
1.16. Using the same values for a, b, and n as in the previous example, the conclusion evaluates
as
a3
a3 − b3
≡
=
b3 (mod n)
ny
=
3y
−63 =
−21 =
3y
y,
13 − 43
and y is an integer.
1.17. Using the same values for a, b, and n as in the previous example, we’ll also let k = 2.
Then we have the same hypothesis as the other examples and the conclusion is the same
as example 1.15.
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
14
C HAPTER 1. D IVIDE AND C ONQUER
1.18. Using the same values for a, b, and n as in the previous example, we’ll also let k = 1.
Then we have the same hypothesis and conclusion as example 1.17.
Question 1.20 Let a, b, c, and n be integers for which ac ≡ bd ( mod n) . Can we conclude
that a ≡ b ( mod n)? If you answer “yes”, try to give a proof. If you answer “no”, try to
give a counterexample.
before Let n, a, b, c, d be 2, 2, 1, 1, 2 respectively. We have
ac − bd
= nx
0
= 2x.
2 · 1 − 1 · 2 = 2x
2 − 2 = 2x
Since 0 is an integer, we have ac ≡ bd ( mod n) . Now assume that a ≡ b ( mod n). Then
∃y ∈ Z such that
a − b = ny
2 − 1 = 2y
1
1
2
But y ∈ Z so y 6=
terexample.after
1
2
= 2y
= y.
which means we have a contradiction. Therefore we have found a coun-
Theorem 1.21 Let a natural number n be expressed in base 10 as
n = ak ak−1 · · · a1 a0 .
If m = ak + ak−1 + · · · + a1 + a0 , then n ≡ m ( mod 3) .
Proof. Let a natural number n be expressed in base 10 as
n = ak ak−1 · · · a1 a0
and let m ∈ N such that
m
=
ak + ak−1 + · · · + a1 + a0
k
=
∑ ai .
i=0
N UMBER T HEORY
P ROOFS AND H OMEWORK
15
1.2. D IVISIBILITY AND C ONGRUENCE
Since each digit place a0 , a1 , a2 , a3 , . . . in the base 10 representation of n represents
1, 10, 100, 1000, . . . = 100 , 101 , 102 , 103 , . . . ,
we can rewrite n as
k
n = ∑ 10i ai .
i=0
Then
k
k
n − m = ∑ 10i ai − ∑ ai .
i=0
i=0
Since addition is associative and both our sums use the same index, we can rewrite n − m as
k
∑
n−m =
i=0
k
∑
=
i=0
k
∑
=
i=0
10i ai − ai
10i−1 · 10ai − ai
10i−1 · 9ai .
We can then factor out 3 to obtain
k
n − m = 3 ∑ 10i−1 · 3ai .
i=0
Since integers are closed under addition and multiplication, there exists x ∈ Z such that
k
x = ∑ 10i−1 · 3ai .
i=0
Then n − m = 3x which means that n ≡ m ( mod 3) .
Theorem 1.22 If a natural number is divisible by 3, then, when expressed in base 10, the
sum of its digits is divisible by 3.
Proof. Let n ∈ N such that n = 3x for some x ∈ Z. When expressed in base 10,
n
= ak ak−1 · · · a1 a0
k
3x
=
∑ 10iai .
i=0
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
16
C HAPTER 1. D IVIDE AND C ONQUER
Let m be the sum of the digits of n. So we then have
k
m = ∑ ai .
i=0
By Theorem 1.21, we know there exists some y ∈ Z such that
n − m = 3y.
We then find
n =
3x =
3x − 3y =
3 (x − y) =
3y + m
3y + m
m
m.
Now, since (x − y) ∈ Z, we have 3|m.
Theorem 1.23 If the sum of the digits of a natural number expressed in base 10 is divisible
by 3, then the number is divisible by 3 as well.
Proof. Let n ∈ N such that when expressed in base 10,
n
= ak ak−1 · · · a1 a0
Now assume that m, the sum of the digits of n is divisible by 3. Then there exists x ∈ Z such
that m = 3x. By Theorem 1.21, we know there exists y ∈ Z such that
n − m = 3y.
Then by substitution, we find
n − 3x =
n =
=
Since y + x ∈ Z, we conclude that 3|n.
N UMBER T HEORY
3y
3y + 3x
3 (y + x).
P ROOFS AND H OMEWORK
17
1.3. T HE D IVISION A LGORITHM
Exercise 1.24 Devise and prove other divisibility criteria similar to the preceding one.
Conjecture 1 Given a natural number n, if the least significant digit is divisible by 2, then
2 | n.
Proof. Let n ∈ N which when written as digits, we have
n = dm . . . d2 d1 ,
and assume that 2 | d1 . Then
n = dm . . . d3 d2 0 + d1
and d1 = 2x where x ∈ Z. Now let
k
=
dm . . . d3 d2 0
=
=
10 · dm . . . d3 d2
2 (5 · dm . . . d3 d2 ) .
Then by closure properties of Z, ∃y ∈ Z such that
y = 5 · dm . . . d3 d2 ,
which then gives us
k = 2y.
So we write
n =
=
=
k + d1
2y + 2x
2 (y + x)
and ∃z ∈ Z with z = y + x. Therefore
n = 2z =⇒ 2 | n,
which completes our proof.
1.3
T HE D IVISION A LGORITHM
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
18
C HAPTER 1. D IVIDE AND C ONQUER
Exercise 1.25 Illustrate the Division Algorithm for:
1. m = 25, n = 7.
2. m = 277, n = 4.
3. m = 33, n = 11.
4. m = 33, n = 45.
Theorem 1.26 Prove the existence part of the Division Algorithm.
Let n, m ∈ N. To show that there exist integers q and r such that m = nq + r with
0 ≤ r ≤ n − 1, consider the set
Proof.
A = {m − nx | m − nx > 0, x ∈ Z} .
Since integers are closed under multiplication, and we restrict the set to positive numbers, we
may conclude that all elements in A are natural numbers. Then by the Well-Ordering Axiom for
the Natural Numbers, we know that A has a smallest element; call it r. Then
r = m − nq
for some q ∈ Z. Solving for m, we obtain
m
=
nq + r,
and therefore we have proven the existence of q and r.
Theorem 1.27 Prove the uniqueness part of the Division Algorithm.
Proof. Let m, n ∈ N and suppose q, q′ and r, r′ are any integers that satisfy
N UMBER T HEORY
m
=
nq + r
m
=
nq′ + r′
P ROOFS AND H OMEWORK
19
1.3. T HE D IVISION A LGORITHM
with 0 ≤ r, r′ < n. Then
nq + r = nq′ + r′
nq − nq′ = r′ − r
n q − q′ = r′ − r.
Since 0 ≤ r, r′ < n, we know that −n < r′ − r < n. Additionally, since q and q′ are integers,
∃x ∈ Z with q − q′ = x. Thus
−n < nx < n.
Therefore we know that −1 < x < 1. Since x ∈ Z, we are left with the only option x = 0. Thus
q = q′ which also implies that r = r′ .
Theorem 1.28 Let a, b, and n be integers with n > 0. Then a ≡ b ( mod n) if and only if
a and b have the same remainder when divided by n.
Proof. Since a ≡ b ( mod n) , a − b = nx for some x ∈ Z. The Division Algorithm guarantees
q1 , q2 and r1 , r2 such that
a
b
= nq1 + r1 ,
= nq2 + r2 ,
0 ≤ r2 < n
0 ≤ r2 < n.
Then
a − b = nx
nq1 + r1 − nq2 − r2 = nx
nq1 − nq2 − nx = r2 − r1
n (q1 − q2 − x) = r2 − r1 .
Since ∃y ∈ Z such that q1 − q2 − x = y, we have
ny = r2 − r1 .
Now, 0 ≤ r1 , r2 < n, and by Theorem 1.27,
r2 − r1
r2
= 0
= r1 .
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
20
C HAPTER 1. D IVIDE AND C ONQUER
1.4
G REATEST C OMMON D IVISORS
AND
L INEAR D IOPHANTINE E QUATIONS
Question 1.29 Do every two integers have at least one common divisor?
Question 1.30 Can two integers have infinitely many common divisors?
Exercise 1.31 Find the following greatest common divisors. Which pairs are relatively
prime?
1. (36, 22) = 2
2. (45, −15) = 15
3. (−296, −88) = 8
4. (0, 256) = 256
5. (15, 28) = 1
6. (1, −2436) = 1
The last two are relatively prime.
Theorem 1.32 Let a, n, b, r, and k be integers. If a = nb + r and k|a and k|b then k|r.
Proof. Since k|a and k|b, ∃x, y ∈ Z such that
a =
kx
b =
ky.
Then
a =
kx =
kx − nky =
k (x − ny) =
N UMBER T HEORY
nb + r
nky + r
r
r.
P ROOFS AND H OMEWORK
1.4. G REATEST C OMMON D IVISORS AND L INEAR D IOPHANTINE E QUATIONS
Since x − ny ∈ Z, we have k|r.
21
Theorem 1.33 Let a, n1 , b, r1 , be integers with a and b not both 0. If a = n1 b + r1 then
(a, b) = (b, r1 ) .
Proof. Since a
Theorem 1.38 Let a and b be integers. If gcd (a, b) = 1, then there exist integers x and y
such that ax + by = 1.
Proof. Let a and b be integers such that gcd (a, b) = 1. By the closure properties of the integers,
we know that for any x, y ∈ Z, there is some z ∈ Z such that ax + by = z. Additionally, since z
is an integer, we know that 1 | z and hence 1 | ax + by. Now, we’ll define a set of all ax + by for
all integers x and y. So let
A = {ax + by | x, y ∈ Z} .
We then wish to only consider the positive elements in A, so let
A+ = {a ∈ A | a > 0} .
By the Well-Ordering Axiom for the Natural Numbers, we can say there is a smallest element
in A+ , which we’ll call d. We wish to show that d must be equal to 1. We then use the Division
Algorithm to find integers q and r such that
a = qd + r,
0 ≤ r < d.
Now, since d ∈ A, ∃x1 , y1 ∈ Z such that d = ax1 + by1 . Then
a =
a − q (ax1 + by1) =
a − qax1 − qby1 =
a (1 − qx1) + b (−qy1 ) =
q (ax1 + by1 ) + r
r
r
r,
which means that r ∈ A as well. But, since d is the smallest positive element in A and 0 ≤ r < d,
r must be 0. Therefore d divides a. Similarly, we do the same for b and find
b = q2 (ax1 + by1) + r2
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
22
C HAPTER 1. D IVIDE AND C ONQUER
which leads us to r2 ∈ A and thus r2 must also be 0. Then d also divides b.
Now, we have that d | a and d | b, and d is a positive number, but by our hypothesis, the
greatest common divisor of a and b is 1, so d = 1.
Theorem 1.41 Let a, b, and c be integers. If a | bc and (a, b) = 1, then a | c.
Proof. Let a, b, and c be integers such that a | bc and a and b are relatively prime. Since a | bc,
∃d ∈ Z such that bc = ad. Also, since (a, b) = 1, by Theorem 1.38, we know there exist integers
x and y such that ax + by = 1. We then multiply both sides of this equation by c to obtain
= acx + bcy
c
= acx + (ad)y
= a (cx + dy).
Then by closure properties of integers, we have some z ∈ Z such that
z = cx + dy.
Then
c = az,
which implies that a | c and proves our theorem.
Exercise 1.54 Find all integer solutions to the equation 24x + 9y = 33.
We have x0 = 1 and y0 = 1 are solutions to this equation, so the set of solutions is given by
x
9k
3
= 1 + 3k
= 1+
and
y
=
=
N UMBER T HEORY
24k
3
1 − 8k.
1−
P ROOFS AND H OMEWORK
1.4. G REATEST C OMMON D IVISORS AND L INEAR D IOPHANTINE E QUATIONS
23
Blank Paper Exercise 1.59 After not looking at the material in this chapter for a day or
two, take a blank piece of paper (or LATEXeditor!) and outline the development of that
material in as much detail as you can without referring to the text or to notes. Places
where you get stuck or can’t remember highlight areas that may call for further study.
Chapter 1 was mostly review material about modular arithmetic and divisibility. This chapter covered proofs and techniques that were developed in the intro to proofs class and formed a
foundation for the algebraic properties of modular arithmetic. Additionally, the division algorithm was covered, seeing that it is very much related. The chapter finishes by applying what
was so far learned on solving linear Diophantine equations using the greatest common divisor
and least common multiple of pairs of numbers.
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
24
N UMBER T HEORY
C HAPTER 1. D IVIDE AND C ONQUER
P ROOFS AND H OMEWORK
CHAPTER 2
PRIME TIME
2.1
T HE F UNDAMENTAL T HEOREM
OF
A RITHMETIC
Exercise 2.6 For each natural number n, define π (n) to be the number of primes less than
or equal to n.
1. Graph π (n) for n = 1, 2, . . . , 100
25
20
15
10
5
20
40
60
80
100
2. Make a guess about approximately how large π (n) is relative to n. In particular, do you
26
C HAPTER 2. P RIME T IME
suspect that π (n)
n is generally an increasing function or a decreasing function? Do you
suspect that it approaches some specific number (as a limit) as n goes to infinity? Make a
conjecture and try to prove it. Proving your conjecture is a difficult challenge. You might
use a computer to extend your list of primes to a much larger number and see whether
your conjecture seems to be holding up.
Since π (n) must always be less than n, this is a decreasing function.
k
2
4
6
8
10
0.6
ΠHnk L
nk
0.4
0.2
0.0
10
8
6
4
n
2
From this graph, it appears that
π (n)
n
will approach zero.
Exercise 2.10 Express n = 12! as a product of primes.
In [ 1 ] : = F a c t o r I n t e g e r [ 1 2 ! ]
Out [ 1 ] = { { 2 , 1 0 } , { 3 , 5 } , { 5 , 2 } , { 7 , 1 } , { 1 1 , 1 } }
This output is interpreted as
210 · 35 · 52 · 71 · 111 .
Exercise 2.11 Determine the number of zeroes at the end of 25!.
N UMBER T HEORY
P ROOFS AND H OMEWORK
2.2. A PPLICATIONS OF
THE
27
F UNDAMENTAL T HEOREM OF A RITHMETIC
In [ 2 ] : = n = 0 ; While [ I n t e g e r D i g i t s [ 2 5 ! ] [ [ − ( n + 1 ) ] ] = = 0 , n + + ] ; n
Out [ 2 ] = 6
2.2
A PPLICATIONS
OF THE
F UNDAMENTAL T HEOREM
OF
A RITHMETIC
Exercise 2.14 Find gcd 314 · 722 · 115 · 173, 52 · 114 · 138 · 17 .
In [ 3 ] : = GCD[ 3 ^ 1 4 7^22 11^5 1 7 ^ 3 , 5 ^ 2 11^4 13^8 1 7 ]
Out [ 3 ] = 248897
Exercise 2.15 Find lcm 314 · 722 · 115 · 173, 52 · 114 · 138 · 17 .
Theorem 2.19 There do not exist natural numbers m and n such that 7m2 = n2 .
Proof. Let m, n ∈ N and assume that 7m2 = n2 . We will then attempt to derive a contradiction.
Since 7 is an integer, we know that m2 divides n2 . By Theorem 2.13, we then say m | n. So there
exists some x ∈ Z such that n = mx. We then use substitution to write
7m2
=
(mx)2
7m2
=
m2 x 2
x2
x.
√
However, x ∈ Z, so we have a contradiction since 7 6∈ Z. We then conclude that no such m
and n exist in N where 7m2 = n2 .
√
MAT-306—S PRING 2012
7 =
7 =
R ICHARD H ENNIGAN
28
C HAPTER 2. P RIME T IME
In [ 4 ] : = LCM[ 3 ^ 1 4 7^22 11^5 1 7 ^ 3 , 5 ^ 2 11^4 13^8 1 7 ]
Out [ 4 ] = 3017529075 45 4 03 9 73 5 93 5 31 9 47 0 71 4 94 5 57 0 33 3 24 0 75
Theorem 2.20 There do not exist natural number m and n such that 24m3 = n3 .
r
r
r
s
s
rj
Proof. Let p11 p22 . . . pkk be the prime factorization of a natural number m and q11 q22 . . . q j the
prime factorization of a natural number n.
We will next assume that 24m3 = n3 . Now, since n
√
3
is a natural number, this must mean that 24m3 is also a natural number. But
√
√
√
3
3
24m3 =
24 · 3 m
√
3
= 2 3m
√
and 3 3 is not a natural number, so we have reached a contradiction. Therefore there exist no
such m, n ∈ N.
Exercise 2.21 Show
√ that
and m such that 7 = mn .
Proof. Assume that
√
7 is irrational. That is, there do not exist natural numbers n
√
7 is rational. Then we can write
√
n
7= ,
m
where n and m are reduced to lowest terms. Now if we square both sides, we have
7
7m2
n2
m2
= n2 .
=
r
r
Let pr11 pr22 . . . pkk and qs11 qs22 . . . q j j be the unique prime factorizations of m and n, respectively.
We then write
rk 7 pr11 pr22 . . . pk
7m2 =
r =
pr11 pr22 . . . pkk
n2
r
r
qs11 qs22 . . . q j j qs11 qs22 . . . q j j .
Now suppose that k is an even number. Then there exists x ∈ Z with k = 2x and our left side of
the equation has
1 + 2x + 2x = 2 (2x) + 1
N UMBER T HEORY
P ROOFS AND H OMEWORK
2.2. A PPLICATIONS OF
THE
29
F UNDAMENTAL T HEOREM OF A RITHMETIC
factors, which is an odd number. Alternatively, if k is odd, there exists a x ∈ Z with k = 2x + 1
and our left side of the equation has
1 + 2x + 1 + 2x + 1 = 4x + 2 + 1
= 2 (2x + 1) + 1
factors, which is again an odd number. But if j is even, then ∃y ∈ Z such that j = 2y and we
have
2y + 2y = 2 (2y)
factors on the right, which is even. If j is odd, then ∃y ∈ Z such that j = 2y + 1 and
2y + 1 + 2y + 1 =
=
4y + 2
2 (y + 1).
Again, we have an even number of factors on the right. Now since mn was already in lowest
terms, we cannot reduce these numbers any further by factoring. So we have
√ contradicted the
uniqueness part of the Fundamental Theorem of Arithmetic, and therefore 7 is not rational.
Theorem 2.26 Let p be prime and let a be an integer. Then p does not divide a if and only
if gcd (a, p) = 1.
Proof. Let p be prime and a ∈ Z and suppose that p does not divide a. We can write the prime
factorization of a as
a = ab11 ab22 · · · abnn .
If p appeared in this factorization then we would have
b −1
a = a p ab11 · · · a pp · · · abnn ,
where a p = p. But that would mean that p divides a which violates our hypothesis. Since the
only divisors of p are p and 1, we must conclude that the greatest common divisor of a and p
must be 1.
Conversely, if gcd (a, p) = 1, then p does not divide a, otherwise p would be a common
divisor of a and p and p > 1.
Theorem 2.27 Let p be a prime and let a and b be integers. If p | ab, then p | a or p | b.
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
30
C HAPTER 2. P RIME T IME
Proof. Let p ∈ P and a, b ∈ Z and assume that p | ab. Since ab must be a natural number, we
can write the unique prime factorization as
ab = pr11 · pr22 · · · prmm .
Then by Theorem 2.12, there exists i ∈ N with 1 ≤ i ≤ m such that p = pri i . Then p appears in
the prime factorization of a, b, or both.
Case 1. If p appears in the prime factorization of a, then
a = ac11 · ac22 · · · acnn · p,
and since ac11 · ac22 · · · acnn ∈ Z, p | a.
Case 2. If p appears in the prime factorization of b, then
d
b = bd11 · bd22 · · · bk k · p,
d
and since bd11 · bd22 · · · bk k ∈ Z, p | b.
Therefore, we conclude that if p divides ab, p will also divide a or b.
Theorem 2.32 For all natural numbers n, gcd (n, n + 1) = 1.
Proof. Let n be any natural number and assume d | n and d | n + 1. Then there exists x ∈ Z
such that
n = dx
and consequently,
n + 1 = dx + 1.
Since d | n + 1, we know that
dx + 1
∈ Z,
d
which means that
x+
1
∈ Z.
d
Now, since x is an integer, d must be 1, otherwise
conclude that gcd (n, n + 1) = 1.
N UMBER T HEORY
1
d
would be less than 1. Since d = 1, we
P ROOFS AND H OMEWORK
2.2. A PPLICATIONS OF
THE
31
F UNDAMENTAL T HEOREM OF A RITHMETIC
Theorem 2.37 If r1 , r2 , . . . , rm are natural numbers and each one is congruent to 1 modulo
4, then the product r1 r2 · · · rm is also congruent to 1 modulo 4.
Proof. Let r1 , r2 , . . . , rm ∈ N such that ri − 1 = 4xi for some xi ∈ Z for all i ∈ {1, 2, . . . , m}. Then
ri − 1 =
ri =
4xi
4xi + 1.
Now let p j be a product of j different elements in {x1 , x2 , . . . , xm } . For example, there’s only
one product pm which is x1 x2 · · · xm , but there are (m − 1)! products of the form p2 , which we
denote as p2,1 , p2,2 , . . . , p2,(m−1)! . We then write out the expansion of r1 r2 · · · rm as1
r1 r2 · · · rm
= (4x1 + 1)(4x2 + 1)· · · (4xm + 1)
= 4m pm + 4m−1 p2,1 + . . . + 4m−1 p2,(m−1)! + . . . + 4x1 + . . .4xm + 1.
Now, subtracting 1 from both sides and factoring 4 on the right, we obtain
r1 r2 · · · rm − 1 =
=
4m pm + 4m−1 p2,1 + . . . + 4m−1 p2,(m−1)! + . . . + 4x1 + . . . 4xm
4 4m−1 pm + 4m−2 p2,1 + . . . + 4m−2 p2,(m−1)! + . . . + x1 + . . . xm .
Therefore, we conclude that r1 r2 · · · rm ≡ 1 (mod 4) .
Theorem 2.38 (Infinitude of 4k+3 Primes Theorem). There are infinitely many primes
that are congruent to 3 modulo 4.
Proof. (by contradiction). Assume the number of primes congruent to 3 modulo 4 is finite.
Then there exists n ∈ N such that p1 , p2 , . . . , pn are the only primes that are congruent to 3
modulo 4. Then for each i ∈ {1, . . . , n}, there exists xi such that
pi − 3 = 4xi .
Now let
q
=
=
4p1 p2 · · · pn − 1
4 (p1 p2 · · · pn ) + 3.
1 There was probably a much cleaner way of doing this proof, but I didn’t leave myself enough time to try to work
on other angles.
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
32
C HAPTER 2. P RIME T IME
Then q ≡ 3 (mod 4) and pi ≡ 3 (mod 4) . By Theorem 1.14, we know
qpi ≡ 9 (mod 4)
which implies that there exists zi ∈ Z such that
qpi − 9 = 4zi
qpi − 1 = 4zi + 8
= 4 (zi + 2).
Since zi + 2 ∈ Z, we have
qpi ≡ 1 (mod 4) ,
wh
Exercise 2.48 Express each of the first 20 even numbers greater than 2 as a sum of two
primes. (For example: 8 = 5 + 3.)
N UMBER T HEORY
P ROOFS AND H OMEWORK
2.2. A PPLICATIONS OF
THE
F UNDAMENTAL T HEOREM OF A RITHMETIC
4
= 2+2
6
8
= 3+3
= 5+3
33
10 = 7 + 3
12 = 7 + 5
14 = 11 + 3
16 = 11 + 5
18 = 11 + 7
20 = 13 + 7
22 = 5 + 17
24 = 19 + 5
26 = 7 + 19
28 = 17 + 11
30 = 23 + 7
32 = 19 + 13
34 = 29 + 5
36 = 23 + 13
38 = 31 + 7
40 = 37 + 3
42 = 29 + 13.
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
34
N UMBER T HEORY
C HAPTER 2. P RIME T IME
P ROOFS AND H OMEWORK
CHAPTER 3
A MODULAR WORLD
3.1
P OWERS
AND
P OLYNOMIALS M ODULO n
Question 3.4 Using paper and pencil, but no calculator, can you find the natural number
k, 0 ≤ k ≤ 11, such that 39453 ≡ k ( mod 12)?
We first obtain the binary expansion of 453, which is
n−1
453 =
∑ ai 2i
i=0
a ∈ {0, 1}
= 1 · 20 + 0 · 21 + 1 · 22 + . . . + 1 · 27 + 1 · 28
= 1 + 4 + 64 + 128 + 256.
We then use the fact that for integers a and b, if a ≡ b mod n, then ak ≡ bk mod n, which was
2
2
proved in Theorem 1.18. So if a2 ≡ b2 mod n, then a2 ≡ b2
mod n. We then have
39453
= 39(256+128+64+4+1)
2 2 2 2 2 2 2 2
. . . 392 . . . (39) .
=
392
Then
8 i ai
k = ∏ 392
i=0
mod 12.
36
C HAPTER 3. A M ODULAR W ORLD
Since each 392 reduces to a remainder of 9 when divided by 12, and 39 itself reduces to 3, we
have
(9) (9) (9) (9) (3)
mod 12 =
(81 mod 12) (81 mod 12)(3 mod 12)
=
=
(9 mod 12)(9
27 mod 12
=
3.
mod 12)(3)
Exercise 3.5 Show that 39 divides 1748 − 524.
Proof. Let
a = 1748
mod 39
b = 524
mod 39.
and
We wish to show that a = b. The binary expansions for 48 and 24 are
48 =
32 + 16
24 =
16 + 8.
Then
1748
=
n−1 ∏
172
i=0
5
i
ai
=
172 · 172
=
n−1 4
and
524
i
∏
52
4
3
i=0
=
ai
52 · 52 .
We have
172
52
mod 39 =
mod 39 =
1
1,
So a = 1 and b = 1. Then 1748 ≡ 524 mod 39 and by definition, 39| 1748 − 524 .
N UMBER T HEORY
P ROOFS AND H OMEWORK
37
3.1. P OWERS AND P OLYNOMIALS M ODULO n
Theorem 3.13 Suppose f (x) = an xn + an−1 xn−1 + . . . + a0 is a polynomial of degree n > 0
with integer coefficients. Then f (x) is a composite number for infinitely many integers x.
Proof. Suppose that
A = { f (x) : ∃n ∈ N such that n < f (x) and n| f (x)}
is finite. Let x ∈ Z such that f (x) ∈ A. Then ∃m ∈ N : m| f (x) . So we have
m| an xn + an−1xn−1 + . . . + a0
and thus
an xn + an−1xn−1 + . . . + a1x ≡ −a0
Since x ∈ Z and n > 0, we know
xn
mod m.
∈ Z as well. We then have
f (xn ) = an (xn )n + an−1 (xn )n−1 + . . . + a0.
Exercise 3.18 Find all solutions in the appropriate canonical complete residue system
modulo n that satisfy the following linear congruences:
1. 26x ≡ 14 mod 3
x ∈ {1 + 3k : k ∈ Z}
2. 2x ≡ 3 mod 5
x ∈ {4 + 5k : k ∈ Z}
3. 4x ≡ 7 mod 8
0/
4. 24x ≡ 123 mod 213
x ∈ {14 + 17k : k ∈ Z}
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
38
C HAPTER 3. A M ODULAR W ORLD
Theorem 3.19 Let a, b, and n be integers with n > 0. Show that ax ≡ b mod n has a
solution if and only if there exist integers x and y such that ax + ny = b.
Proof. Suppose ax ≡ b mod n. Then ∃z ∈ Z such that
ax − b = nz.
Then we rewrite this as
ax − nz = b,
and since z ∈ Z, ∃y ∈ Z such that y = −z. Then
ax + ny = b.
For the converse, suppose that there are integers x and y such that ax + ny = b. Then
ax − b =
ax − b =
and thus n| (ax − b) which means
ax ≡ b
−ny
n (−y) ,
mod n.
Exercise 3.22 Use the Euclidean Algorithm to find a member x of the canonical complete
residue system modulo 213 that satisfies 24x ≡ 123 mod 213. Find all members x of the
canonical complete residue system modulo 213 that satisfy 24x ≡ 123 mod 213.
x ∈ {14 + 17k : k ∈ Z}
Exercise 3.26 (Brahmagupta, 7th century A.D.). When eggs in a basket are removed two,
three, four, five or six at a time, there remain, respectively, one, two, three, four, or five
eggs. When they are taken out seven at a time, none are left over. Find the smallest number
of eggs that could have been contained in the basket.
N UMBER T HEORY
P ROOFS AND H OMEWORK
39
3.1. P OWERS AND P OLYNOMIALS M ODULO n
Let e be the number of eggs in the basket. Then
e − 1 = 2x1
e − 2 = 3x2
e − 3 = 4x3
e − 4 = 5x4
e − 5 = 6x5
e
= 7x6 .
So we have
e
e
e
e
e
e
≡ 1
mod 2
≡ 4
≡ 5
mod 5
mod 6
≡ 2
≡ 3
mod 3
mod 4
≡ 0
mod 7.
e ∈ {119 + 420 |k| : k ∈ Z} .
Thus the smallest number of eggs is
min {119 + 420 |k| : k ∈ Z} = 119.
Blank Paper Exercise 3.30 After not looking at the material in this chapter for a day or
two, take a blank piece of paper (or LATEXeditor!) and outline the development of that
material in as much detail as you can without referring to the text or to notes. Places
where you get stuck or can’t remember highlight areas that may call for further study.
Chapter 3 revisits modular arithmetic in more detail and instead of viewing it as only an
equivalence class, we begin to think about mod as an operation (mainly by using the Division
Algorithm). Much of this material is review from Abstract Algebra, since cyclic groups were
covered at great length. Although the notation is different, the concepts remain the same. This
chapter helped develop an intuition for algorithmic problem solving as well, particularly when
dealing with large exponents in modular arithmetic.
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
40
N UMBER T HEORY
C HAPTER 3. A M ODULAR W ORLD
P ROOFS AND H OMEWORK
CHAPTER 4
FERMAT’S LITTLE THEOREM AND
EULER’S THEOREM
4.1
O RDERS
OF AN INTEGER MODULO
n
Exercise 4.1 For i = 0, 1, 2, 3, 4, 5, and 6, find the number in the canonical complete
residue system to which 2i is congruent modulo 7. In other words, compute 20 mod 7,
21 mod 7,. . . ,26 mod 7.
In[204]:=
Out[204]=
TableAModA2i , 7E, 8i, 0, 6<E
81 , 2 , 4 , 1 , 2 , 4 , 1 <
Theorem 4.2 Let a and n be natural numbers with (a, n) = 1. Then a j , n = 1 for any
natural number j.
Proof. Let the unique prime factorization of a be
b
a = ab11 · ab22 · · · ak k
and the unique prime factorization of n be
m
m2
q
1
n = nm
1 · n2 · · · nq .
42
C HAPTER 4. F ERMAT ’ S L ITTLE T HEOREM AND E ULER ’ S T HEOREM
Since (a, n) = 1, neither of these share a factor. Let j be any natural number. Then
b j
aj =
ab11 · ab22 · · · ak k
=
b j
a1b1 j · a2b2 j · · · ak k .
Since the base of the exponents
has not changed, a j does not share a common factor with n
j
either. Therefore a , n = 1.
Theorem 4.3 Let a, b, and n be integers with n > 0 and (a, n) = 1. If a ≡ b mod n, then
(b, n) = 1.
Proof. Since (a, n) = 1, there exist integers x, y such that ax + ny = 1. Additionally, since a ≡ b
mod n, we have a − b = nz for some integer z. Then with substitution, we write
ax + ny =
1
(nz + b)x + ny =
bx + nzx + ny =
1
1
bx + n (zx + y) =
1.
Since zx + y is an integer, we conclude that (b, n) = 1 as well.
Theorem 4.4 Let a and n be natural numbers. Then there exist natural numbers i and j,
with i 6= j, such that ai ≡ a j mod n.
Proof. Let a, n ∈ N. By Theorem 3.14, we know there is a unique integer t in
B = {0, 1, 2, . . . , n − 1}
such that a ≡ t mod n. Consider the set
A = a1 , a2 , a3 , . . . , an , an+1 .
For each ai ∈ A, there is a unique t j ∈ B such that ai ≡ t j mod n. However, there are n + 1
elements in A and only n elements in B. Therefore there must be some t ∈ B, ai , a j ∈ A with
i 6= j where
ai
a
N UMBER T HEORY
j
≡ t
≡ t
mod n
mod n.
P ROOFS AND H OMEWORK
43
4.2. F ERMAT ’ S L ITTLE T HEOREM
We then conclude that
ai ≡ a j
mod n.
4.2
F ERMAT ’ S L ITTLE T HEOREM
Exercise 4.19 Compute each of the following without the aid of a calculator or computer.
1. 512372 mod 13 = 1
2. 34443233 mod 17 = 10
3. 123456 mod 23 = 16
Exercise 4.20 Find the remainder upon division of 314159 by 31.
314159 mod 31 = 8.
4.3
E ULER ’ S T HEOREM
AND
W ILSON ’ S T HEOREM
Exercise 4.27 The numbers 1, 5, 7, and 11 are all the natural numbers less than or equal
to 12 that are relatively prime to 12, so φ (12) = 4.
1. φ (7) = 6
2. φ (15) = 8
3. φ (21) = 12
4. φ (35) = 24.
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
44
N UMBER T HEORY
C HAPTER 4. F ERMAT ’ S L ITTLE T HEOREM AND E ULER ’ S T HEOREM
P ROOFS AND H OMEWORK
APPENDIX A
THE FINAL PROJECT
A.1
T HE P ROBLEM
We don’t often think about how a computer calculates something, we just give it some input
and (usually in very short time) it gives us the appropriate output. Sometimes, the use of algorithms can actually speed up a computation instead of directly computing the result. This means
that the computer takes many more steps in the computation, which is nonintuitive. However,
there are certain physical limitations to be considered, particularly when dealing with very large
numbers. To illustrate this problem, let a = 12345678 and b = 12345678. These are both fairly
large numbers, but to a computer, they are miniscule. Compare the number of bytes needed to
store a to the number 1.
ByteCount@aD
ByteCount@1D
In[51]:=
Out[51]=
24
Out[52]=
24
It turns out that as far as Mathematica is concerned, these numbers are of equal size. However, if we were to evaluate ab , the resulting number wouldn’t even fit on this page at a grand
total of 87,549,561 digits. It’s a pretty big number, and Mathematica seems to agree.
ByteCount@a^ bD
In[54]:=
Out[54]=
36
354
216
This can lead to problems when running computations involving ab , since the time needed
to write and read that much information to memory is significant. As an example, suppose we
46
C HAPTER A. T HE F INAL P ROJECT
wanted to know the remainder left over when dividing ab by 100. We can calculate this directly
by using the Mod function and find how much CPU time is used as follows.
Mod@a^ b, 100D  Timing
In[55]:=
Out[55]=
84.41
, 64
<
Although Mathematica is able to find the answer (64), we would like to see if we can
optimize this computation a bit. In this case, it took 4.414 seconds of CPU time, and over
36 megabytes just to temporarily store the number in memory. We’ll capitalize on the fact that
a and b are tiny 24-byte numbers and use some facts from number theory to devise a better
algorithm.
A.2
T HE A LGORITHM
We’ll first utilize the binary expansion of b, as was used in Question 3.4 and we have
n−1
∑ ci 2 i
b=
c ∈ {0, 1} .
i=0
We can extract the necessary powers of 2 of the terms of this series and place into a list as
follows.
powers =
Thread@Times@Reverse@IntegerDigits@b, 2DD,
Table@i, 8i, 0, Length@IntegerDigits@b, 2DD - 1<DDD
In[73]:=
80 , 1 , 2 , 3 , 0 , 0 , 6 , 0 , 8 , 0 , 0 , 0 ,
0 , 13 , 14 , 0 , 0 , 0 , 18 , 91 , 02 , 21 , 0 , 23
Out[73]=
ByteCount@powersD
In[74]:=
Out[74]=
<
80
We’re still in good shape, using only 808 bytes for this list. Next, we’ll use the fact that
n−1 i ai
ab = ∏ a2
i=0
to generate the list below.
list = TableANestAModAð 2 , nE &, a, dE, 8d, exp<E
Out[109]=
884
N UMBER T HEORY
, 96
, 96
, 96
, 96
, 96
, 96
, 96
, 96
, 96
, 96
, 96
<
P ROOFS AND H OMEWORK
47
A.3. P ERFORMANCE
If we then multiply these values together, we have some k where
k ≡ ab
mod n.
We can now finally calculate the result, and we see that we obtain 64 as intended.
k = Times žž 884, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96<
In[112]:=
536
12
Out[112]=
63
546
43
30
864
ByteCount@kD
In[114]:=
56
Out[114]=
Mod@k, 100D
In[115]:=
Out[115]=
037
64
This was all done using a tiny fraction of the memory needed for a direct calculation. We
now wish to see if this algorithm is actually faster.
A.3
P ERFORMANCE
The next step is to build all of this into a single function that takes any integers as arguments
and not just the example we have chosen. We build the function modAlgorithm as follows.
In[116]:=
modAlgorithm@a_Integer, b_Integer, n_IntegerD := I
powers =
Thread@Times@Reverse@IntegerDigits@b, 2DD,
Table@i, 8i, 0, Length@IntegerDigits@b, 2DD - 1<DDD;
exp = Select@powers, ð ¹ 0 &D;
list = TableANestAModAð 2 , nE &, a, dE, 8d, exp<E;
k = Times žž list;
Mod@k, nD
M
We then test the performance by comparing the CPU timing with the direct computation
method.
In[118]:=
Out[118]=
Timing@modAlgorithm@12 345 678, 12 345 678, 100DD
80.
, 64
<
This method is fast enough to not even register any time with the Timing function.
MAT-306—S PRING 2012
R ICHARD H ENNIGAN
Download