23
Number Theory Number Theory 이이이 School of Information Technology Sungshin W. University

Number Theory 이재원 School of Information Technology Sungshin W. University

Embed Size (px)

Citation preview

Number TheoryNumber Theory

이재원School of Information Technology

Sungshin W. University

DivisionDivision

• DEFINITION 1 If a and b are integers with a≠0, we say that a divides b if there is an integer c such that b=ac. When a divides b we say that a is a factor of b and that b is a multiple of a. The notation a | b denotes that a divides b. We write a ł b when a does not divide b.

ex) 3 ł 7, 3|12

Division Cont.Division Cont.

• THEOREM 1 Let a, b, and c be integers. Then(i) if a | b and a | c, then a | (b + c);(ii) if a | b and a | bc, for all integers c;(iii) if a | b and b | c, then a | c.

• COROLLARY 1 If a, b, and c are integers such that a | b and a | c then a | mb + nc whenever m and n are integers.

Division Cont.Division Cont.

• THE DIVISION ALGORITHM Let a be an integer and d a positive integer. Then there are unique integers q and r, with 0 ≤ r < d, such that a = dq + r.

• THEOREM 2 In the equality given in the division algorithm, d is called the divisor, a is called the dividend, q is called the quotient, and r is called the remainder.

• q = a div d, r = a mod d. (101/11?, -11/3?)

Modular ArithmeticModular Arithmetic

• DEFINITION 3 If a and b are integers and m is a positive integer, then a is congruent to b modulo m if m divides a – b.

a b (mod m)

• THEOREM 3 Let a and b be and let m be a positive integer, then a b (mod m) if and only if a mod m = b mod m.

• 17 5 (mod 6) ? Yes. 24 14 (mod 6) ? No.

Modular Arithmetic Cont.Modular Arithmetic Cont.

• THEOREM 4 Let m be a positive integer. The integer a and b are congruent modulo m if and only if there is an integer k such that a = b + km

• THEOREM 5 Let m be a positive integer. If a b (mod m) and c d (mod m), then

(a + c) (b + d) (mod m) and ac bd (mod m) .

ex) 7 2 (mod 5) and 11 1 (mod 5) => 18 3 (mod 5) and 77 2 (mod 5)

Modular Arithmetic Cont.Modular Arithmetic Cont.

• COROLLARY 2 Let m be a positive integer and let a and b are integers. Then,

(a + b) mod m = ((a mod m) + (b mod m)) mod m and ab mod m = ((a mod m)(b mod m)) mod m Proof) a (a mod m) (mod m) and b (b mod m) (mod m) -> a + b (a mod m) + (b mod m) (mod m) …

Applications of CongruencesApplications of Congruences

• Hashing Functions h(k) = k mod m• Pseudorandom Numbers xn+1= (axn+ c) mod m

• Ex) if we choose m=9, a=7, c=4, and x0=3, we get 3, 7, 8, 6, 1, 2, 0, 4, 5, 3, 7, 8, 6, …

Applications of CongruencesApplications of Congruences

• Cryptology

Caesar’s encryption: f (p) = (p + 3) mod m

• EXAMPLE 9 secret message from “MEET YOU IN THE PARK” using Caesar’s cipher?

12 4 4 19 24 14 20 8 13 19 7 4 15 0 17 10 15 7 7 22 1 17 23 11 16 22 10 7 18 3 21 13 “PHHW BRX LQ WKH SUDN”• enhancing security: f (p) = (ap + b) mod 26

Primes and GCDsPrimes and GCDs

• DEFINITION 1 A positive integer p greater than 1 is called prime if the only positive factors of p are 1 and p. A positive integer that is greater than 1 and is not prime is called composite.

• The primes less than 100 are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, and 97.

Primes and GCDsPrimes and GCDs

• THEOREM 2 If n is a composite integer, then n has a prime divisor less than or equal to .

• EXAMPLE 3 Show that 101 is prime. Solution: The only primes not exceeding

are 2, 3, 5, and 7. …

• EXAMPLE 4 Find the prime factorization of 7007.

7007/7 = 1001, 1001/7 = 143, … 7007 = 72·11·13

n

101

Representation of IntegersRepresentation of Integers

• THEOREM 1 Let b be a positive integer greater than 1. Then if n is a positive integer, it can be expressed uniquely in the form

n= akbk + ak-1bk-1 + … + a1b1 + a0

Where k is a nonnegative integer, a0, a1, …, ak are nonnegative integers less than b and ak ≠ 0.

Cont.Cont.

• The representation of n given in Theorem 1 is called base b expansion of n. The base b expansion of n is denoted by (akak-1…a1a0)b

• For instance, (245)8 represents 2·82 + 4·8 + 5 = 165.

Cont.Cont.

• Example 1 What is the decimal expansion of the integer that has (1 0101 1111)2 as its binary expansion?

• Solution: (1 0101 1111)2 = 1·28 + 0·27 + 1·26 + 0·25 + 1·24 + 1·23 + 1·22 + 1·21 + 1·20 = 351.

Cont.Cont.

• Example 3 Find the base 8, or octal, expansion of (12345)10.

Solution: 12345 = 8·1543 + 1. 1543 = 8·192 + 7.

192 = 8·24 + 0. 24 = 8·3 + 0. 3 = 8·0 + 3. (12345)10 = (30071)8

Modular ExponentiationModular Exponentiation

• Example 11 Find 3644 mod 645.

Solution: - 644 를 2 진수로 표현하면 (1010000100)2 이다 .

따라서 644 = 29 + 27 + 22 이며 , 3644 = (3 의 29 승 ) · (3의 27 승 ) · (3 의 22 승 ) 이다 .

- 세 수의 곱을 645 로 나눈 나머지는 각각의 수를 644 로 나눈 나머지들을 모두 곱한 후 다시 645 로 나눈 나머지와 같다 ( 교재 205 페이지의 따름정리(corollary) 2 참고 ).

- 이 원리를 이용하여 만들어진 알고리즘 5 에 의해 ,

Modular Exponentiation Cont.Modular Exponentiation Cont.• i=0: a0=0, x=1, p=32 mod 645 = 9 mod 645 = 9;• i=1: a1=0, x=1, p=92 mod 645 = 81 mod 645 = 81 (3 의 22 승 );• i=2: a2=1, x=(1·81) mod 645 = 81, p=812 mod 645 = 6561 mod

645 = 111; ( (6561 · 6561) mod 645 = (111 · 111) mod 645 ) • i=3: a3=0, x=81, p=1112 mod 645 = 12,321 mod 645 = 66;• i=4: a4=0, x=81, p=662 mod 645 = 4356 mod 645 = 486;• i=5: a5=0, x=81, p=4862 mod 645 = 236,196 mod 645 = 126;• i=6: a6=0, x=81, p=1262 mod 645 = 15,876 mod 645 = 396;• i=7: a7=1, x=(81·396) mod 645 = 471, p=3962 mod 645 =

156,816 mod 645 = 81;• i=8: a8=0, x=471, p=812 mod 645 = 6561 mod 645 = 111;• i=9: a9=1, x=(471·111) mod 645 = 52,281 mod 645 = 36.

Modular Exponentiation Cont.Modular Exponentiation Cont. ALGORITHM 5 Modular Exponentiation Procedure modular exponentiation(b: integer, n = (ak-1ak-2, …, a1a0)2, m: positive integer) x := 1 power := b mod m for i = 0 to k -1 begin if ai = 1 then x := (x · power) mod m

power := (power · power) mod m end (x equals bn mod m)

The Euclidean AlgorithmThe Euclidean Algorithm

• More efficient method of finding the greatest common divisor

• Finding gcd(91, 287) - 287 = 91 · 3 + 14 - any divisor of 91 and 287 must also be a divisor of

287 - 91 · 3 = 14. Also, any divisor of 91 and 14 must also be a divisor of 287 = 91 · 3 + 14.

- Hence, the greatest common divisor of 91 and 287 is the same as the greatest common divisor of 91 and 14.

The Euclidean Algorithm Cont.The Euclidean Algorithm Cont.

- This means that the problem of finding gcd(91, 287) has been reduced to the problem of finding gcd(91, 14).

- Next, divide 91 by 14 to obtain - 91 = 14 · 6 + 7 - Continue by dividing 14 by 7(gcd(91, 14) = gcd(14, 7)) - 14 = 7 · 2 - Because 7 divides 14, it follows that gcd(14, 7) = 7.

Furthermore, because gcd(287, 91) = gcd (91, 14) …, the original problem has been solved.

The Euclidean Algorithm Cont.The Euclidean Algorithm Cont.

• LEMMA 1 Let a = bq + r, where a, b, q, and r are integers. Then gcd(a, b) = gcd(b, r).

• Proof: Suppose that d divides both a and b. Then d also divides a – bq = r (from Theorem 1 of section 3.4). Hence, any common divisor of a and b is also a common divisor of b and r.

Likewise, suppose that d divides both b and r. Then d also divides bq + r = a. Hence, any common divisor of b and r is also a common divisor of a and b. => gcd(a, b) = gcd(b, r)

The Euclidean Algorithm Cont.The Euclidean Algorithm Cont.• EXAMPLE 12 Find the greatest common divisor

of 414 and 662.• Solution: Successive uses of the division

algorithm give: 662 = 414 · 1 + 448 414 = 248 · 1 + 166 248 = 166 · 1 + 82 166 = 82 · 2 + 2 82 = 2 · 41. Hence, gcd(414, 662) = 2, because 2 is the last nonzero

remainder.

The Euclidean Algorithm Cont.The Euclidean Algorithm Cont. ALGORITHM 6 The Euclidean Algorithm Procedure gcd(a, b: positive integers) x := a y := b while y ≠ 0 begin r := x mod y

x := yy := r

end (gcd(a, b) is x)