




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















Unit NT
In this section, we shall take a look at some of the most basic properties of Z, the set of inte- gers. We look at properties related to parity (even, odd), prime factorization, irrationality of square roots, and modular arithmetic.
First we recall some standard notation for sets of various basic types of numbers.
Note that R − Q is the set of irrational numbers.
Example 1 (Odd and even integers) A basic subdivision of Z is into the odd integers and the even integers. An element of Z is even if it is “of the form 2t,” where t ∈ Z. An element of Z is odd if it is not even. The odd integers are all of the form 2t + 1, where t ∈ Z. (This should be proved, but we will not do so.) The phrase “of the form 2t” can be written precisely as
∀ n ∈ Z, (n is even) if and only if (∃ t ∈ Z such that n = 2t).
The most elementary mathematical facts about odd and even integers concern the closure properties.^1 Here is the closure property for multiplication:
The integers m and n are both odd if and only if mn is odd.
(Equivalently, by negating both sides of “if and only if,” at least one the integers m or n is even if and only if mn is even. ) To show the “only if” part, suppose that if m and n are both odd, say m = 2j +1 and m = 2k +1. Then mn = 4jk +2j +2k +1 = 2(2jk +j +k) + is of the form 2t + 1 where t = 2jk + j + k. Thus, mn is odd. To show the “if” part, we use the inverse. Suppose that at least one of m or n is even. Without loss of generality, we may suppose that m is even, say m = 2j. Then mn = 2jn is of the form 2t where t = jn. Thus, mn is even. A similar statement for addition is that, for integers m and n, m + n is odd if and only if one of them is odd and the other is even.
(^1) A function on S × S has the closure property on S if its image is contained in S. Here
S is the odd integers and the function is multiplication.
Number Theory and Cryptography
From the closure property for multiplication of odd integers, you can prove by induction that for any k ≥ 1, and any integer m, mk^ is odd if and only if m is odd. Logically equivalent is that mk^ is even if and only if m is even. The fact that mk^ is odd if m is odd can also be proved using the binomial theorem, which you should have seen in high school:
(x + y)k^ =
∑^ k
i=
k i
xiyk−i.
Since m is odd, m = 2j + 1 for some integer j. Let x = 2j and y = 1. Written another way,
mk^ = (2j + 1)k^ = 1 + (2j)^1
k 1
k 2
k k
In this form mk^ is obviously 1 plus an even integer and hence odd.
Most mathematicians would agree that the most important concept in number theory is the notion of a prime.
Definition 1 (Prime and composite numbers) A natural number n is prime if n ≥ 2 and the only divisors of n are n and 1. We denote the set of prime numbers by P. An integer n ≥ 2 that is not prime is composite.
The number 2 is the smallest prime and the only even prime. The other primes less than 20 are 3, 5, 7, 11, 13, 17, 19.
Example 2 (Prime factorization of any integer n ≥ 2 ) Consider the integer 226512. It ends in 2 so it is divisible by 2. (We say that “n is divisible by m,” indicated by the notation m | n, if n = qm for some integer q.) In fact, 226512/2 = 113256. We can divide by 2 again, 113256/2 = 56628; and again, 56628/2 = 28314; and again, 38314/2 = 14157. That’s it. We can’t divide by 2 anymore, so we have 226512 = 2^4 × 14157. But, it is easy to check that 14157 is divisible by 3 to get 4719 which is again divisible by 3 to get 1573. That’s it for dividing by 3, so we have 226512 = 2^4 × 32 × 1573. Continuing in this manner, we end up with 226512 = 2^4 × 32 × 112 × 13. We have written 226512 as a product of primes. Also, the notation m 6 | n means that n is not divisible by m.
Can every integer greater than 1 be written as a product of primes? What about a single prime p? It is convenient to adopt the terminology that a single prime p is a product of one prime, itself.^2
(^2) We could go even further and say that 1 is also can be written as an empty product.
In fact, mathematicians do this: They say that an empty sum is 0 and an empty product is 1. You may think this strange, but you’ve already seen it with exponents: The notation an^ stands for the product of n copies of a. Thus a^0 is the product of no copies of a, and you learned that we define a^0 = 1 when you studied exponents. This is done so that the rule an+m^ = anam^ will work when n = 0.
Number Theory and Cryptography
Now that we know that every integer n ≥ 2 is a product of powers of primes, we can show
Theorem 2 (Infinitely many primes) There are infinitely many primes.
Proof: Suppose that there were only finitely many primes, say the k primes
P = {p 1 , p 2 ,... , pk}.
Consider the integer n = (p 1 p 2 · · · pk) + 1 gotten by taking the product of all of the primes in P and adding one. Clearly, n /∈ P (it’s too big). That means n is a product of primes. Let p be one of the prime factors of n. Hence n/p is an integer. For pi ∈ P, dividing n by pi leaves a remainder of 1 and so n/pi is not an integer. Since n/p is an integer and n/pi is not, we cannot have p = pi. Hence p /∈ P. Contradiction! Thus there cannot be finitely many primes.
Prime factorization can be used to prove things that apparently do not depend on primes. Our next example illustrates this.
Example 3 (For all n ∈ N,
n is either an integer or irrational) The integer 36 is nice because
36 = 6 and 6 is an integer. Thus 36 is called a perfect square. A perfect square is an integer whose square root is also an integer. Suppose
n is not an integer. How “bad” is it? For example, maybe, though not an integer,
n is rational; that is,
n = a/b for some integers a and b. Sadly, that can’t happen. We prove this by contradiction
Suppose
n = a/b where b ≥ 2 and we have cancelled common factors from the numerator and denominator. Since
n = a/b, we have nb^2 = a^2. Let p be a prime factor of b (p exists since b ≥ 2). Since prime factorization is unique, p is a prime factor of nb^2 = a^2. On the other hand, since p is a prime factor of b, it is not a prime factor of a since we have cancelled common factors to get a and b. So far, we have shown that p is a prime factor of a^2 but not a prime factor of a. In the next paragraph, we show that this is a contradiction.
For any integer x, if the prime factorization of x is x = pe 11 pe 22 · · · pe kk then the prime factorization of x^2 is x^2 = p^21 e 1 p^22 e 2 · · · p^2 ke k. In other words, any integer x has exactly the same prime divisors as its square, x^2. Apply this with x = a. We have proved
Theorem 3 (Irrational square roots) For all n ∈ N,
n is either an integer or irrational.
We can use this to get a lot of irrational numbers. Suppose that k^2 < n < (k + 1)^2 for some k ∈ N. Taking square roots, we have k <
n < k + 1. Thus
n cannot be an integer and so it must be irrational. In particular
8 are all irrational.^4 (^4) Some classical Greeks were bothered by this. They thought there should be a basic
unit of length such that all the lines in a geometrical construction were integer multiples of that length, but they could prove that this was impossible: By the Pythagorean Theorem, the diagonal of a unit square has length
2, which they knew was irrational. If the side of the square were b basic units long and the diagonal were a, then
2 = a/b.
Section 1: Basic Facts About Numbers
There are some basic properties of irrational and rational numbers lurking beneath the surface here. If the product xy of two numbers is irrational, one of the numbers must be irrational. Equivalently (the contrapositive), if x and y are both rational, say x = a/b and y = c/d, then xy = ac/bd is rational. Likewise, if the sum x + y of two numbers is irrational, one of the numbers must be irrational (prove this).
Some students think these statements mean that the product of two nonzero irrational numbers is irrational and the sum of two irrational numbers is irrational, both statements are false:
2 = 2 and (−
2 = 0. It is true, however, that if x 6 = 0 is rational and y is irrational, then the product xy is irrational. To prove this statement, use the contrapositive. If xy = a/b then y = a/bx. Since x 6 = 0 is rational, say x = c/d, this implies that y = ad/cb is rational.
Example 4 (The rational numbers are countable) We want to show that we can create a list a 1 , a 2 , a 3 ,... such that every rational number appears on the list. We do this as follows:
Step 1. Start the list with 0, 1 / 1 , − 1 /1 and set k = 3. Step 2. Append to the list all rational numbers in reduced form where the sum of the numerator and denominator (ignoring signs) is k. Begin with the largest numerators and proceed to the smallest, listing positive numbers and then negative ones. (Thus, for k = 3 we append 2/ 1 , 1 / 2 , − 1 / 2 , − 2 /1 and for k = 4 we append 3/ 1 , 1 / 3 , − 1 / 3 , − 3 /1.) Step 3. Increase k by one and go to Step 2.
The list begins
a 1 = 0, a 2 = 1 /1, a 3 = − 1 /1, k = 3 : a 4 = 2 /1, a 5 = 1 /2, a 6 = − 1 /2, a 7 = − 2 /1, k = 4 : a 8 = 3 /1, a 9 = 1 /3, a 10 = − 1 /3, a 11 = − 3 /1, k = 5 : a 12 = 4/1, a 13 = 3/2, a 14 = 2/3, a 15 = 1/4, a 15 = − 1 /4, a 16 = − 2 /3, a 17 = − 3 /2, a 18 − 4 /1,
Note that each rational number occurs exactly once in the list. In some sense, the number of rational numbers is the same as the number of positive integers since we have one rational number for each positive integer (the subscript of a)!
Because we can form such a list, we say that the set of rational numbers is countable. More simply, people say that the rationals are countable.
Example 5 (The real numbers are not countable) We must show that it is impossible to form a list of the real numbers. How can we do this? We must show that, no matter what list of real numbers we have, there is some real number that is not on the list.
Suppose we have a list a 1 , a 2 ,... of real numbers. Let dk be the kth digit after the decimal point in ak. For example, if a 4 = 2. 718281828... (the number e), then d 4 = 2. If dk = 1, let bk = 2 and, if dk 6 = 1, let bk = 1. Look at the number r = 0.b 1 b 2 b 3.. .. We claim it is not in the list. Why is this? Suppose someone claims, for example that a 99 = r. By definition, d 99 is the ninety-ninth digit of a 99 after the decimal point. Since b 99 6 = d 99 , the numbers r and a 99 differ in their ninety-ninth digits. Thus r 6 = a 99.
Section 1: Basic Facts About Numbers
Since the two uses of “mod” involve different placement of “mod,” you should not be confused as to which use is intended.
Example 6 (A fact about remainders) There is something important about remainders that they may not have discussed in elementary school. Suppose x = qd+r and x′^ = q′d+r′. Then, subtracting and dividing by d gives
x − x′ d
(q − q′)d + (r − r′) d
= q − q′^ +
r − r′ d
Note that since 0 ≤ r < d and 0 ≤ r′^ < d we must have 0 ≤ |r−r′| < d. This means that the only way that r−r
′ d can be an integer is that^ |r^ −^ r
′| = 0 or r = r′. This seems like a trivial
point, but it is very important. It means that x and x′^ have the same remainder when divided by d (i.e., belong to the same residue class mod d) if and only if d divides x−x′. For example 7666 and 7652 belong to the same residue class modulo 7 since 7666 − 7652 = 14, which is 0 modulo 7.
The notation x = x′^ (mod d) behaves like equality in many ways. The following theorem lists three of them.
Theorem 4 (Arithmetic with mod) The notation x = x′^ (mod d) behaves like equality for addition, subtraction and multiplication. In other words, if x = x′^ (mod d) and y = y′^ (mod d) then
x + y = x′^ + y′^ (mod d), x − y = x′^ − y′^ (mod d) and xy = x′y′^ (mod d).
We talk about addition modulo d or simply modular addition, and similarly for subtraction and multiplication. Notice that we did not say x/y = x′/y′^ mod d. It is not true in general. For example, 2 = 8 (mod 6) and 2 = 2 (mod 6) but 2/ 2 6 = 8/2 (mod 6).
Proof: We prove addition. By definition x + y = x′^ + y′^ (mod d) means that (x + y) − (x′^ + y′) is divisible by d. But
(x + y) − (x′^ + y′) d
(x − x′) + (y − y′) d
x − x′ d
y − y′ d
Number Theory and Cryptography
Since x = x′^ (mod d) and y = y′^ (mod d), both x − x′^ and y − y′^ are divisible by d. Thus, (x + y) − (x′^ + y′) is divisible by d.
The proof for subtraction is nearly the same as for addition, so we omit it.
We now prove multiplication. Again, we show that xy − x′y′^ is divisible by d:
xy − x′y′ d
x(y − y′) + y′(x − x′) d
= x
y − y′ d
x − x′ d
Since, x = x′^ (mod d) and y = y′^ (mod d), both x − x′^ and y − y′^ are divisible by d. Thus, xy − x′y′^ is divisible by d.
Example 7 (Powers of dZ + 1) Suppose x ∈ dZ + 1. We could equally well write this as x mod d = 1 or x = 1 (mod d) or even just x ≡ 1 provided we know we are doing arithmetic modulo d. We claim that xn^ ≡ 1 for all n ∈ N. The proof is by induction on n.
For n = 0, x^0 = 1 and so x^0 ≡ 1. For n = 1, x^1 = x and so x^1 ≡ 1 since we are given that x ≡ 1. For n > 1, xn^ = (xn−^1 )x. By induction xn−^1 ≡ 1. By the theorem, xn−^1 x ≡ 1 × 1 = 1. We are done.
When d = 2, you should be able to see that this simply states that powers of odd numbers are odd, a fact we proved in Example 1.
Example 8 (Using modular arithmetic cleverly) There are smart ways and dumb ways to use Theorem 4. It is interesting to look first at a dumb way, just to see the power of these statements. Suppose you want to find the remainder when the number N = 113 × (167 + 484) + 192 × 145 is divided by 21. That is, we wish to know N (mod 21). A friend says he is going to help. He tells you that 113 = 95180 (mod 21), 167 = 5159244761 (mod 21), 484 = 9073 (mod 21), 192 = 207441 (mod 21) and 145 = 19857871 (mod 21). He suggests you substitute those larger numbers for the original numbers in the expression N = 113 × (167 + 484) + 192 × 145 to get
M = 95180 × (5159244761 + 9073) + 207441 × 19857871.
He assures you that, if you compute M and divide by 21 you will get the desired remainder r. He says he would like to borrow your car while you do the computations. After several hours work, you get M = 495177116538231. Dividing by 21 gives 15 as a remainder. Thus, r = 15, so N (mod 21) = 15. That is the right answer but it is a dumb way to do it!
Another way is to just compute
N = 113 × (167 + 484) + 192 × 145 = 101403
and divide that by 21 to get the remainder 15. That is not too dumb.
Another way is to note that 113 = 8 (mod 21), 167 = 20 (mod 21), 484 = 1 (mod 21), 192 = 3 (mod 21), 145 = 19 (mod 21). Substitute those for the corresponding numbers to get L = 8(20 + 1) + 3 ∗ 19 = 225. Now divide 225 by 21 to get 15 as the remainder.
A modification on the above is to note that 20 = −1 (mod 21) and 19 = −2 (mod 21) to get L′^ = 8(−1 + 1) + 3(−2) = −6. Dividing −6 by 21 gives a remainder of 15. Did you
Number Theory and Cryptography
1.1. Prove the statement if true, otherwise find a counterexample.
(a) For all natural numbers x and y, x + y is odd if one of x and y even and the other is odd. (b) For all natural numbers x and y, if x + y is odd then one of x and y even and the other is odd.
1.2. Prove the statement if true, otherwise find a counterexample.
(a) The difference of any two odd integers is odd. (b) If the sum of two integers is even, one of them must be even.
1.3. Prove the statement if true, otherwise find a counterexample. (a) The product of two integers is even if and only if at least one of them is even. (b) The product of two integers is odd if and only if at least one of them is odd.
1.4. Prove the statement if true, otherwise find a counterexample. (a) For any integers m and n, m^3 − n^3 is even if and only if m − n is even. (b) For any integers m and n, m^3 − n^3 is odd if and only if m − n is odd.
1.5. Prove the statement if true, otherwise find a counterexample.
(a) For all integers n > 2, n^3 − 8 is composite. (b) For all integers n, (−1)n^ = −1 if and only if n is odd.
1.6. Prove the statement if true, otherwise find a counterexample. (a) ∀ n ∈ Z, n^2 + n + 5 is odd. (b) ∀ n ∈ Z, (6(n^2 + n + 1) − (5n^2 − 3) is a perfect square).
(c) ∃ M > 0, ∀ n > M , (n^2 − n + 11 is prime). (d) There is a unique prime p of the form n^2 + 2n − 3.
1.7. Prove the statement if true, otherwise find a counterexample. (a) For all integers n > 0, either n is a perfect square or, n = x + y where x and y are perfect squares or, n = x + y + z where x, y, and z perfect squares. (b) The product of four consecutive positive integers is never a perfect square.
1.8. Prove the statement if true, otherwise find a counterexample.
Section 1: Basic Facts About Numbers
(a) For all distinct positive integers m and n, either m^1 /^2 + n^1 /^2 and m^1 /^2 − n^1 /^2 are both rational or both irrational. Hint: Consider
m^1 /^2 + n^1 /^2
m^1 /^2 − n^1 /^2
(b) For all distinct positive integers, if either m^1 /^2 +n^1 /^2 or m^1 /^2 −n^1 /^2 are rational then both m and n are perfect squares. (c) For all distinct positive integers m and n, both m and n are perfect squares if and only if m + 2m^1 /^2 n^1 /^2 + n is a perfect square. (d) Which of (a), (b) and (c) are true if m 6 = n is changed to m = n?
1.9. Prove that an integer n > 1 is composite if and only if p divides n for some prime p ≤ n^1 /^2.
1.10. Write the following rational numbers as the ratio a/b of two integers a and b > 0.
(a) 3. 1415 (b) 0. 30303030... (c) 6. 32152152152152...
1.11. Let x ∈ R satisfy the equation ax cx++db = 1 where a, b, c, and d are rational. Is x rational? Explain.
1.12. In each case, if the statement is true, prove it, if false, give a counterexample.
(a) The sum of three consecutive integers is zero (mod 3). (b) The product of two even integers is zero (mod 4).
(c) An integer is divisible by 16 only if it is divisible by 8. (d) For all odd integers n, 3n + 3 is divisible by 6.
1.13. In each case, if the statement is true, prove it, if false, give a counterexample.
(a) ∀ a, b, c ∈ Z, if a | b then a | bc. (b) ∀ a, b, c ∈ Z, if a | b and b | c, then a | c (c) ∀ a, b, c ∈ Z, if a | c then ab | c.
1.14. In each case, if the statement is true, prove it, if false, give a counterexample.
(a) ∀ a, b, c ∈ Z, if a | (b + c) then a | b and a | c.
(b) ∀ a, b, c ∈ Z, if a | bc then a | b or a | c. (c) ∀ a, b ∈ Z, if a | b then a^2 | b^2. (d) ∀ a, b ∈ Z, if a | 6 b then a | 6 or a | b.
1.15. In each case, factor the given number into a product of powers of distinct primes.
Section 2: Cryptography and Secrecy
(a) ∀ x, y ∈ R, (⌊x − y⌋ = ⌊x⌋ − ⌊y⌋). (b) ∀ x ∈ R, ∀ k ∈ Z, (⌊x − k⌋ = ⌊x⌋ − k). (c) ∀ x ∈ R, k ∈ N, (⌊xk⌋ = ⌊x⌋k).
1.27. In each case, if the statement is true, prove it, if false, give a counterexample. (a) ∀ n ∈ Z, k ∈ N+, (⌊ n k ⌋ = n− k r) where r = n % k).
(b) ∀ x ∈ R, ∀ a, b ∈ N+, (⌊ax + b⌋ = a⌊x⌋ + b).
1.28. Prove each of the following statements or give a counterexample. (a) ∀ x ∈ R − Z, (⌊x⌋ + ⌊−x⌋ = −1). (b) ∀ x ∈ R − Z, (⌈x⌉ + ⌈−x⌉ = +1).
Cryptography is concerned with secret messages. Cryptanalysis is the name for the general area of breaking secret codes so the messages can be read. This general topic represents a vast body of knowledge. We begin by introducing the basic ideas and problems. Then we take time out to study some number theory functions that are useful for cryptography on the internet. Finally, we look at two protocols that are currently used — Diffie-Hellman and RSA.
Suppose that Alice wishes to send a message to Bob in such a way that anyone else receiving her message will not be able to understand it. She can communicate in code. There are three pieces of data involved:
The rules for converting can be thought of as functions. If P is the set of all possible plaintext messages and C is the set of all possible ciphertext messages, then the key K determines a function fK : P → C that Alice uses to encipher the message. Bob uses the inverse function f (^) K− 1 to decipher the message. Notice that, in order to decipher, f (^) K− 1 must exist. Thus fK must be an injection. The next example illustrates a simple scheme for doing this.
Number Theory and Cryptography
Example 9 (A simple code) Instead of Alice and Bob, we have two factories A and B that are going to exchange goods. There are 64 different items (coded 0, 1 , 2 ,... 63) to be shipped and four methods of shipping (regular mail represented by the code 00; priority mail, code 01; air mail, code 10; and next day air, code 11). A shipment request looks something like 10101001. The two least significant bits, 01 in this case specify the method of shipping and the other six bits the item in base 2 (101010 or item 42 in this case).
The factories want to keep the orders they are requesting from each other secret from their competitors. To keep things secret, the factories agree on a simple encipherment procedure. They agree on a fixed eight bit binary string that they share as a secret. Here is the secret string that they happen to choose: K = 11000111. This is the shared key, also called the secret key or, simply, the key.
Factory A wants to place order r = 10101001 with factory B. To do this, the folks at A add r to K bit-by-bit using addition mod 2. That is, 0 + 0 = 0, 0 + 1 = 1 + 0 = 1, 1 + 1 = 0. Here is what happens:
10101001 plaintext 11000111 key K 01101110 ciphertext
The first line is the message, the second line is the key, and the third line is the mod 2 bit-by- bit sum of the message and the key. We have just computed fK (10101001). Actually, this is done in the computer. When someone wants to place an order, they type in 10101001. The computer does the addition and sends the result to factory B.
When factory B’s computer receives the ciphertext, it adds the shared key to the ciphertext as follows: 01101110 ciphertext 11000111 key K 10101001 plaintext
This reverses the process and reveals the correct order from factory A. Pretty nifty — the function and its inverse are the same, i.e. f (^) K− 1 = fK.
In the previous example, f (^) K− 1 = fK. This makes programming easier since the software for deciphering is the same as the software for enciphering. As a result, many systems are designed to have f (^) K− 1 = fK.
There is a problem with our simple system (other than the fact that it’s too simple): We can only send an 8-bit message.
Number Theory and Cryptography
We now discuss some number theory functions that are important in cryptography. After we understand them, we’ll use them in the Diffie-Hellman and RSA protocols.
Definition 3 (Greatest common divisor and least common multiple) If k, n and n/k are integers, we write k | n (read “k divides n”) and we call k a divisor of n and we call n a multiple of k. The greatest common divisor of m and n is the largest (positive) k such that k is a divisor of m and k is a divisor of n. It is denoted by gcd(m, n). The least common multiple of m and n is the smallest positive integer k such that k is a multiple of m and k is a multiple of n. It is denoted by lcm(m, n).
For example, if m = 6, its positive divisors are 1, 2, 3 and 6. Its positive multiples are 6 , 12 , 18 ,... The greatest common divisor of 6 and 9 is 3, written gcd(6, 9) = 3. Similarly, lcm(6, 9) = 18.
The gcd(120, 26) = 2. It is also the case that 5 × 120 − 23 × 26 = 2. In other words, there are integers a = 5 and b = −23 such that am + bn = gcd(m, n) where m = 120 and n = 26. This is a fact that is true for any m and n. That is, we claim
Theorem 5 (The gcd as a linear combination) The greatest common divisor of m and n is a linear combination, with integral coefficients, of m and n.
Corollary (All common divisors) An integer k divides m and n if and only if it divides gcd(m, n).
Proof: We can see why this must be true without knowing how to compute the coefficients a and b. The set S = {Am + Bn | A, B ∈ Z, Am + Bn > 0 } is a nonempty set of positive integers (since |m| ∈ S) and therefore has a least element (by common sense at this point). Let am + bn = L be this least element. Note that L | m. If not, we would have m = qL + r, 0 < r < L. Thus,
r = m − qL = m − q(am + bn) = (1 − qa)m − (qb)n ∈ S.
This would contradict the minimality of L since 0 < r < L. Similarly, L | n. Thus, L is a common divisor of m and n. Any integer x that is a common divisor of m and n divides any element Am + Bn of S and thus x | L. Thus, L = gcd(m, n) is the greatest common divisor of m and n. This proves that am + bn = gcd(m, n).
In the last couple of sentences of the previous paragraph, we concluded that, if x divides both m n, then x | gcd(m, n). Conversely, suppose x | gcd(m, n). This means that x divides both m and n. This proves the corollary.
Section 2: Cryptography and Secrecy
Example 11 (Some properties of gcd and lcm) Let n > 0 and m > 0 be positive integers and let n = pe 11 pe 22 · · · pe kk and m = pf 11 pf 22 · · · pf kk be factorizations of m and n into primes where some of the exponents fi or ei may be zero (in order to make k and the list of pi the same for both factorizations). For example, n = 6500 = 2^2 × 53 × 13 and m = 24696 = 2^3 × 32 × 73 would, using this convention, be written as n = 2^2 × 30 × 53 × 70 × 131 and m = 2^3 × 32 × 50 × 73 × 130. The following theorem is the general result of which this example is a special case. We will not prove it. You should think carefully about the example and make up some of your own until you see why the theorem is true.
Theorem 6 (Computing gcd and lcm) If n = pe 11 pe 22 · · · pe kk and m = pf 11 pf 22 · · · pf kk , then gcd(m, n) = pmin( 1 e^1 ,f^1 )pmin( 2 e^2 ,f^2 )· · · pmin( k ek,fk)
and lcm(m, n) = pmax( 1 e^1 ,f^1 )pmax( 2 e^2 ,f^2 )· · · pmax( k ek,fk^ ).
Applying this to 6500 = 2^2 × 30 × 53 × 70 × 131 and 24696 = 2^3 × 32 × 50 × 73 × 130
gives gcd(6500, 24696) = 2^2 × 30 × 50 × 70 × 130 = 4
and lcm(6500, 24696) = 2^3 × 32 × 53 × 73 × 131 = 40131000.
This is really pretty easy!
The theorem has various consequences.
pmin( i ei,fi)pmax( i ei,fi)= pmin( i ei,fi)+max(ei,fi)= pe i i+fi= pe i ipf i i.
The one thing you have to do to use the previous method for computing greatest common divisors and least common multiples is to factor n and m into primes. That can be difficult for big numbers. This method for computing gcd and lcm is more of theoretical or conceptual interest than of practical interest. Commonly available software for your computer will compute the gcd and the lcm quickly and efficiently for most integers that you may be interested in, without having to factor the integers. In the next example, we discuss the method that the software uses.
Section 2: Cryptography and Secrecy
Example 13 (The Euclidean algorithm and Theorem 5) In Theorem 5 we showed that there are a, b ∈ Z so that gcd(m, n) = am + bn, but we had no idea how to compute a and b. The Euclidean algorithm, with a slight modification, allows us to compute the a and b. Suppose we start with m = X 1 and n = X 2 and apply the Euclidean algorithm to get Xt = d = gcd(m, n):
X 1 > X 2 > X 3 > · · · > Xt > Xt+1 = 0.
Let Q 2 , Q 3 ,... , Qt− 1 be the list of quotients associated with the nonzero remainders in this list. Thus, Xi− 1 = QiXi + Xi+1 for i = 2,... , t − 1. Note that Xt− 2 = Qt− 1 Xt− 1 + Xt so gcd(m, n) = Xt = Xt− 2 − Qt− 1 Xt− 1. If t = 3 we would have am + bn = gcd(m, n) with a = 1, b = −Qt− 1 , and our work would be done!
If t > 3, we can continue in the same way. We still have Xt = Xt− 2 − Qt− 1 Xt− 1. We also have Xt− 1 = Xt− 3 − Qt− 2 Xt− 2. If we substitute the second equation into the first, we get Xt = gcd(m, n) as a linear combination with integral coefficients of Xt− 3 and Xt− 2. If t = 4, we are done. Otherwise, using Xt− 2 = Xt− 4 − Qt− 3 Xt− 3 , we get Xt as a linear combination of Xt− 3 and Xt− 4. Note that we are working our way towards getting Xt = gcd(m, n) as a linear combination with integral coefficients of X 1 and X 2. At this point we abandon the general discussion and move to an example.
Consider X 1 = 60 and X 2 = 13. Here is the list of nonzero remainders produced by the Euclidean algorithm: 60 > 13 > 8 > 5 > 3 > 2 > 1.
Thus, t = 7 and gcd(60, 13) = 1. We kept track of the quotients: 4, 1, 1, 1, 1. To make it easier to see the connection between quotients and remainders we can write them in this way 60 > 13 > 8 > 5 > 3 > 2 > 1 4 1 1 1 1
where we see that 60 = 4 × 13 + 8, 13 = 1 × 8 + 5,.. ., 3 = 1 × 2 + 1. Now we start working backwards. 1 = 3 − 1 × 2, 2 = 5 − 1 × 3, so 1 = 2 × 3 − 1 × 5. Next we have 3 = 8 − 1 × 5, so
1 = 2(8 − 5) − 1 × 5 = 2 × 8 − 3 × 5.
Next, 5 = 13 − 1 × 8, so 1 = 2 × 8 − 3(13 − 8) = 5 × 8 − 3 × 13. Finally, 8 = 60 − 4 × 13, so 1 = 5 × 60 − 23 × 13. This is the final answer: 1 = gcd(m, n) = am + bn where m = 60, n = 13, a = 5, and b = −13. You should make up some examples on your own and carry out this computation.
The positive integers k = 1, 5 , 7 , 11 are less than 12 and have no common factors with 12 (i.e., are relatively prime to 12). Another way to say this is gcd(k, 12) = 1. The four numbers, 1, 5, 7, and 11 are the only numbers k with gcd(k, 12) = 1 and 1 ≤ k ≤ 12. For this reason, we say φ(12) = 4. More generally:
Definition 4 (The Euler φ function) We define a function φ(n), with domain the positive integers, to be the number of integers k, 1 ≤ k ≤ n, such that gcd(k, n) = 1. This function is called the Euler φ function.
Number Theory and Cryptography
Example 14 (Properties of the Euler φ function) We have noted that φ(12) = 4. Since gcd(1, 1) = 1, we have φ(1) = 1. For any prime p, we have φ(p) = p − 1 because gcd(k, p) = 1 for k = 1, 2 ,... , p − 1.
Suppose n = pq is the prime factorization of n and p 6 = q. We can list the positive integers less than n that are not relatively prime to n. There are two classes of such numbers. The q multiples of p: p, 2 p, 3 p,... , qp and the p multiples of q: q, 2 q, 3 q,... , pq. Except for qp = pq, these two lists have no numbers in common (why?). Thus, the total number of positive integers less than or equal to n that are not relatively prime to n is q + p − 1. Thus, the number of number less than or equal to n = pq that are relatively prime to n is pq − (p + q − 1) = (p − 1)(q − 1).
The set of numbers less than n that are relatively prime to n has a name. It is called the group of units of n and the numbers in that set are called units. The reason for this name is beyond the scope of our course, but does not involve difficult concepts. The Euler φ function and the group of units come into computer science in connection with computer security. It is the basis for a certain type of encryption known as RSA (discussed below) and is used in a common encryption protocol called PGP (Pretty Good Privacy). The key property that makes the group of units useful in this context is that aφ(n)^ = 1 (mod n) whenever a is a unit. We won’t prove this fact, but let’s look at an example. Suppose n = 12. We know that φ(12) = 4 and that the units are { 1 , 5 , 7 , 11 }. Clearly 1φ(12)^ = 1 (mod 12). What about the other units? We have 5^2 = 25 = 1 (mod 12). Thus 5^4 = 1^2 = 1 (mod 12). We could do the same calculations for 7 and 11. Here’s another way. Since 7 = −5 (mod 12), 7^4 = (−1)^454 = 5^4 = 1 (mod 12). Likewise, 11 = −1 (mod 12) and so 11^4 = (−1)^4 = 1 (mod 12). You may have noticed that a^2 = 1 (mod 12) for all units a. There’s no guarantee that φ(n) is the least power for which aφ(n)^ = 1 (mod n) for all units a.
If n = pq then, since φ(n) = (p − 1)(q − 1), this property becomes
m(p−1)(q−1)^ = 1 (mod pq) when gcd(m, pq) = 1.
This fact will be important in our discussion of the RSA protocol.
Suppose two people — Alice and Bob — wish to communicate secretly, but anyone can eavesdrop on there conversation. How can they do this? We already saw in Example 9 how they could do this, and we saw how some problems could arise because of espionage. There’s another problem we haven’t mentioned. What if Alice and Bob don’t have a secret key K that they both know?
Cryptography on the internet addresses this. It uses “public-information algorithms”: No prior secret communication between Alice and Bob is needed — it’s all done publicly. There are two approaches in use.