Math 243 Discrete Mathematical Structures Chapter 4: Number Theory

advertisement
Math 243
Discrete Mathematical Structures
Chapter 4: Number Theory
Back in chapters 1 and 2, I stated that you may
assume that an integer is odd iff it is not even. It
is not too difficult to prove that no integer is BOTH
even and odd:
Proof: Suppose (for a contradiction) that n is both
even and odd. Then n = 2k for some integer k, and
n = 2` + 1 for some integer `. But then 2k = 2` + 1,
1
which means k − ` = . However, k − ` ∈ ZZ is an
2
1
integer, and
isn’t; this contradiction proves the
2
theorem.
But how are we to prove that an integer can be even
OR odd?
4.1. Divisibility [and Modular Arithmetic]
The Division Theorem (Algorithm): If a is an integer,
and d is a positive integer, there are unique integers q
and r such that 0 ≤ r < d and a = qd + r. (q and r are
the quotient and remainder when a is divided by d.)
(The existence proof, when a is nonnegative, will be
given in Chapter 5.)
If r = 0, then a = qd, and a is said to be divisible by
d, and the notation d | a is used. (This can also be
expressed as “d is a factor of a” or “d is a divisor of
a”.) Generally, d | a iff (∃q ∈ ZZ)(a = qd).
The following are true, if a is an integer, and
b and c are posititive integers. (I will prove one of
these in class.)
• If a | b and a | c, then a | (b + c).
• If a | b and b | c, then a | c.
• If a | b then a | (bc).
A brief digression, to 4.3: Primes and GCDs
A number n is said to be prime iff it has exactly two
divisors (which must be 1 and n). Note that 1 is not
prime; we will see why it shouldn’t be considered
one later. If you have a number and you want to
determine whether it’s prime, you can
√ do so by
dividing by the numbers 2, 3, 4, 5, . . . , n and checking
whether you have a remainder of zero. If you ever
get a zero remainder, the number n is not prime
(and you have found another divisor of n); otherwise,
n is prime.
Exercise. Is 53 prime? Is 77 prime?
Primes are “building blocks” of numbers, with
respect to multiplication:
Fundamental Theorem of Arithmetic. Given a positive
integer n, there is exactly one way to write n in
the form p1 e1 p2 e2 · · · pk ek , where p1 , . . . , pk are distinct
prime numbers (in increasing order), and e1 , . . . , ek
are positive integers. This expression is called the
prime factorization of n.
(If 1 was considered a prime, this would not be true,
because 3 = 3 = 1 · 3 = 12 · 3 = 13 · 3 = · · ·. Also, the
prime factorization of 1 is the “empty product”.)
The greatest common divisor of two positive integers m
and n is the largest integer D = gcd(m, n) which is a
divisor of both m and n.
The least common multiple of m and n is the
smallest integer M = lcm(m, n), into which m and n
divide into without a remainder.
Exercise. What is gcd(m, n) and lcm(m, n) if
m = 1400 = 23 · 52 · 71 and n = 2058 = 21 · 31 · 73 ? (Note: A
prime number p is a factor of n iff it is a factor of one
of the primes in n’s prime factorization.)
Prime factorizations are nice, but costly; no one
knows whether one can be found in polynomial time.
Fortunately, the GCD can be found using the Euab
, the
clidean Algorithm. (Since lcm(a, b) =
gcd(a, b)
LCM can also be found without finding a prime
factorization first.)
The idea is to divide a by b (if a > b) to get a
remainder r; then
gcd(a, b) = gcd(b, r).
Repeat with smaller numbers until you can “eyeball”
the answer. (If r = 0, then gcd(a, b) = b.) This does
run in polynomial time, incidentally.
Example. Find gcd(391, 276) and lcm(391, 276).
391 = 1
· 276 + ....115
..
276 = 2
· 115 + .... 46
..
115 = 2
· 46 + ..... 23
..
46 = 2
· 23 + 0
....
..........
...........
...........
. ...........
...................
.....
......
........
...........
....
...........
...........
..........
. ............
.................
......
.....
. ......
...........
.....
..........
...........
..........
. ...........
.................
.....
.....
........
...........
Then gcd(391, 276) = 23 and lcm(391, 276) =
4692.
391 · 276
=
23
Back to 4.1. [Divisibility and] Modular Arithmetic
Back to considering remainders. When a = qd + r,
the number r (the remainder) is sometimes written
as a mod d, and q (the quotient) is sometimes written
as a div d. (Remember that 0 ≤ r, so (−2) mod 3 = 1,
not −2.)
Arithmetic can be done where we only consider
the remainders of integers; this is called modular arithmetic.
How do we know that it works?
We say that m and n are congruent modulo d (written
m ≡ n (mod d)) if m mod d = n mod d, which is
equivalent to d | (m − n), which is further equivalent
to the statement (∃k ∈ ZZ)(m = n + kd).
Suppose a, b, c, d are integers and m is a positive
integer, and suppose further that a ≡ b (mod m) and
c ≡ d (mod m). Then:
1. a + c ≡ b + d (mod m), and
2. ac ≡ bd (mod m).
(Part (1) is proven in your book; I will do part (2)
in class.) Note that we can have ac 6≡ bd (mod m),
though. Otherwise, we can work with just the
remainders.
Calculate the following:
1. (13729435865220974 · 945378995231652709) mod 10.
2. 9453789952316527092 mod 10.
3. 213729435865220974 mod 10.
These operations have a lot of the properties of
real-number addition and multiplication: They are
commutative and associative, the distributive law is
true, 0 and 1 behave the way you expect them to,
and additive inverses exist.
However, you may be lacking multiplicative
inverses; for instance, there is no integer a such that
3a ≡ 1 (mod 15), so 3 does not have a multiplicative
inverse when working modulo 15.
Exercise. When working modulo 15, only the integers
1, 2, 4, 7, 8, 11, 13, 14 have multiplicative inverses. For
each of these numbers n, find its multiplicative
inverse. (For instance, 2 · 8 ≡ 1 (mod 15), so 8 is the
multiplicative inverse of 2: 8 = 2−1 .)
One application of modular arithmetic: The ISBN
(International Standard Book Number) is a way of
assigning numbers to books. The 10-digit ISBN for
your textbook is 0-07-338309-0. The digits a1 , . . . , a10
10
X
are chosen so that
i · ai ≡ 0 (mod 11):
i=1
1·0+2·0+3·7+4·3+5·3+6·8+7·3
+ 8 · 0 + 9 · 9 + 10 · 0 = 198 ≡ 0 (mod 11).
This is used to avoid errors caused by swapping
adjacent digits (there is no book with ISBN
0-07-383309-0) or replacing one digit by another
(there is no ISBN of 0-05-338309-0, either). If you
need a10 = 10, then the “digit” used is X.
Download