Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

CMSC Discrete Structures

Presentasi serupa


Presentasi berjudul: "CMSC Discrete Structures"— Transcript presentasi:

1 CMSC 203 - Discrete Structures
Number Theory Fall 2002 CMSC Discrete Structures

2 Introduction to Number Theory
Number theory is about integers and their properties. We will start with the basic principles of divisibility, greatest common divisors, least common multiples, and modular arithmetic and look at some relevant algorithms. Fall 2002 CMSC Discrete Structures

3 CMSC 203 - Discrete Structures
Pembagian Sifat Pembagian pada Bilangan Bulat Misalkan a dan b adalah bilangan bulat dengan syarat a ≠ 0. Bilangan a habis membagi b jika terdapat bilangan bulat c sedemikian sehingga b = ac. Notasi: a | b jika b = ac, c Z dan a ≠ 0. (Z = himpunan bilangan bulat) Pernyataan “a habis membagi b“ ditulis juga “b kelipatan a”. Contoh : 3 | 6, (6 : 3 = 2 atau 6 = 3x2, 2 bil. Bulat) Fall 2002 CMSC Discrete Structures

4 Divisibility Theorems
For integers a, b, and c it is true that if a | b and a | c, then a | (b + c) Example: 3 | 6 and 3 | 9, so 3 | 15. if a | b, then a | bc for all integers c Example: 5 | 10, so 5 | 20, 5 | 30, 5 | 40, … if a | b and b | c, then a | c Example: 4 | 8 and 8 | 24, so 4 | 24. Fall 2002 CMSC Discrete Structures

5 CMSC 203 - Discrete Structures
Bilangan Prima Bilangan p adalah Bilangan prima jika p adalah bilangan bulat positip yang > 1 dan hanya mempunyai faktor : 1 dan p. (p = 2, 3, 5, 7, 11, 13, 17, 19 dst.) Bilangan bulat positip yang > 1 dan bukan bilangan prima disebut bilangan komposit (composite). 9 bukan b.prima disebut komposit. Setiap bilangan bulat positip dapat ditulis secara unik (tunggal) sebagai perkalian dari bilangan prima , dimana factor b. primanya ditulis urut mulai yg terkecil. Contoh : 6 = 2.3 ; 25 = 5.5 , 100 = = 22.52 Fall 2002 CMSC Discrete Structures

6 CMSC 203 - Discrete Structures
Primes Examples: 15 = 3·5 48 = 2·2·2·2·3 = 24·3 17 = 17 100 = 2·2·5·5 = 22·52 512 = 2·2·2·2·2·2·2·2·2 = 29 515 = 5·103 28 = 2·2·7 Fall 2002 CMSC Discrete Structures

7 Division q the quotient d the divisor a the dividend r the remainder
Remember long division? 117 = 31· a = dq + r q the quotient d the divisor a the dividend r the remainder L9

8 The Division Algorithm
Teorema 1 (Teorema Euclidean). Misalkan m dan n adalah bilangan bulat dengan syarat n > 0. Jika m dibagi dengan n maka terdapat dua buah bilangan bulat unik q (quotient) dan r (remainder), sedemikian sehingga berlaku : m = nq + r , dengan 0  r < n. In the above equation, n is called the divisor, m is called the dividend, q is called the quotient, and r is called the remainder. Fall 2002 CMSC Discrete Structures

9 The Division Algorithm
Example: When we divide 17 by 5, we have 17 = 53 + 2. 17 is the dividend, 5 is the divisor, 3 is called the quotient, and 2 is called the remainder. Fall 2002 CMSC Discrete Structures

10 The Division Algorithm
Another example: What happens when we divide -11 by 3 ? Note that the remainder cannot be negative. -11 = 3(-4) + 1. -11 is the dividend, 3 is the divisor, -4 is called the quotient, and 1 is called the remainder. Fall 2002 CMSC Discrete Structures

11 Pembagi Bersama Terbesar (PBB)
Misalkan a dan b adalah dua buah bilangan bulat tidak nol. Pembagi bersama terbesar (PBB – greatest common divisor atau gcd) dari a dan b adalah bilangan bulat terbesar d sedemikian sehingga d | a dan d | b. Dalam hal ini dinyatakan bahwa PBB(a, b) = d. Example 1: What is gcd(48, 72) ? The positive common divisors of 48 and 72 are 1, 2, 3, 4, 6, 8, 12, 16, and 24, so gcd(48, 72) = 24. Example 2: What is gcd(19, 72) ? The only positive common divisor of 19 and 72 is 1, so gcd(19, 72) = 1. Contoh 3. PBB(45,36) Faktor pembagi 45: 1, 3, 5, 9, 15, 45; Faktor pembagi 36: 1, 2, 3, 4, 9, 12, 18, 36; PBB(45, 36) = 9. Fall 2002 CMSC Discrete Structures

12 Greatest Common Divisors
Using prime factorizations: a = p1a1 p2a2 … pnan , b = p1b1 p2b2 … pnbn , where p1 < p2 < … < pn and ai, bi  N for 1  i  n gcd(a, b) = p1min(a1, b1 ) p2min(a2, b2 ) … pnmin(an, bn ) Example: a = 60 = b = 54 = gcd(a, b) = = 6 Min(2,1) =1, min(3,1)=1 dan min(1,0) = 0

13 Greatest Common Divisor Relatively Prime
Q: Find the following gcd’s: gcd(11,77) gcd(33,77) gcd(24,36) gcd(24,25) L9

14 Bilangan Relatif Prima
Definition: Two integers a and b are relatively prime if gcd(a, b) = 1. Jika a dan b relatif prima, maka terdapat bilangan bulat m dan n sedemikian sehingga : ma + nb = 1 Examples: Are 15 and 28 relatively prime? Yes, gcd(15, 28) = 1. Are 35 and 28 relatively prime? No, gcd(35, 28) = 7. Bagaimana dengan : 20 dan 3 ?, 7 dan 11?, serta 20 dan 5? PBB(20,3) =1 dan (-1)20 = 1 (ada m = 7 dan n = -1) Fall 2002 CMSC Discrete Structures

15 Relatively Prime Integers
Definition: The integers a1, a2, …, an are pairwise relatively prime if gcd(ai, aj) = 1 whenever 1  i < j  n. Examples: Are 15, 17, and 27 pairwise relatively prime? No, because gcd(15, 27) = 3. Are 15, 17, and 28 pairwise relatively prime? Yes, because gcd(15, 17) = 1, gcd(15, 28) = 1 and gcd(17, 28) = 1. Fall 2002 CMSC Discrete Structures

16 Kelipatan Persekutuan Terkecil (Least Common Multiples) - KPC
Definition: The least common multiple of the positive integers a and b is the smallest positive integer that is divisible by both a and b. We denote the least common multiple of a and b by lcm(a, b). Examples: lcm(3, 7) = 21 lcm(4, 6) = 12 lcm(5, 10) = 10 Fall 2002 CMSC Discrete Structures

17 Least Common Multiples
Using prime factorizations: a = p1a1 p2a2 … pnan , b = p1b1 p2b2 … pnbn , where p1 < p2 < … < pn and ai, bi  N for 1  i  n lcm(a, b) = p1max(a1, b1 ) p2max(a2, b2 ) … pnmax(an, bn ) Example: a = 60 = b = 54 = lcm(a, b) = = 4275 = 540 Pangkat dr b.prima yg diambil yg terbesar Fall 2002 CMSC Discrete Structures

18 CMSC 203 - Discrete Structures
GCD and LCM a = 60 = b = 54 = gcd(a, b) = = 6 lcm(a, b) = = 540 Theorem: ab = gcd(a,b)lcm(a,b) Fall 2002 CMSC Discrete Structures

19 CMSC 203 - Discrete Structures
Modular Arithmetic Let a be an integer and m be a positive integer. We denote by a mod m the remainder when a is divided by m. Examples: 9 mod 4 = 1, sisa dr pembagian 9 dan 4 9 mod 3 = 9 mod 10 = 9 -13 mod 4 = 3 Fall 2002 CMSC Discrete Structures

20 CMSC 203 - Discrete Structures
Congruences Let a and b be integers and m be a positive integer. We say that a is congruent to b modulo m if m divides a – b. We use the notation a  b (mod m) to indicate that a is congruent to b modulo m. In other words: a  b (mod m) if and only if a mod m = b mod m. Fall 2002 CMSC Discrete Structures

21 CMSC 203 - Discrete Structures
Congruences Examples: Is it true that 46  68 (mod 11) ? Yes, because 11 | (46 – 68). Is it true that 46  68 (mod 22)? Yes, because 22 | (46 – 68). For which integers z is it true that z  12 (mod 10)? It is true for any z{…,-28, -18, -8, 2, 12, 22, 32, …} (z – 12 habis dibagi 10) Theorem: Let m be a positive integer. The integers a and b are congruent modulo m if and only if there is an integer k such that a = b + km. Fall 2002 CMSC Discrete Structures

22 CMSC 203 - Discrete Structures
Congruences Theorem: 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). Fall 2002 CMSC Discrete Structures

23 Algoritma Euclidean Algoritma Euclidean
Algoritma Euclidean adalah algoritma untuk mencari PBB dari dua buah bilangan bulat. Euclid, penemu algoritma Euclidean. Diberikan dua buah bilangan bulat tak-negatif m dan n (m n). Algoritma Euclidean berikut mencari pembagi bersa 1. Jika n = 0 maka m adalah PBB(m, n); stop. tetapi jika n ≠ 0, lanjutkan ke langkah 2. 2. Bagilah m dengan n dan misalkan r adalah sisanya. 3. Ganti nilai m dengan nilai n dan nilai n dengan nilai r, lalu ulang kembali ke langkah 1.

24 Contoh : Euclidean Algorithm
The Euclidean Algorithm finds the greatest common divisor of two integers a and b. Contoh gcd(287, 91) ? we divide 287 by 91: 287 = 91 We know that for integers a, b and c, if a | b and a | c, then a | (b + c). Therefore, any divisor of 287 and 91 must also be a divisor of 3 = 14. Consequently, gcd(287, 91) = gcd(14, 91). Fall 2002 CMSC Discrete Structures

25 Contoh : The Euclidean Algorithm
In the next step, we divide 91 by 14: 91 = 146 + 7 This means that gcd(14, 91) = gcd(14, 7). So we divide 14 by 7: 14 = 72 + 0 We find that 7 | 14, and thus gcd(14, 7) = 7. Therefore, gcd(287, 91) = 7. Fall 2002 CMSC Discrete Structures

26 Aplikasi MD : Simple Encryption
Variations on the following have been used to encrypt messages for thousands of years. Convert a message to capitals. Think of each letter as a number between 1 and 26. Apply an invertible modular function to each number. Convert back to letters (0 becomes 26). L9

27 Letter  Number Conversion Table
D E F G H I J K L M 1 2 3 4 5 6 7 8 9 10 11 12 13 N O P Q R S T U V W X Y Z 14 15 16 17 18 19 20 21 22 23 24 25 26 L9

28 Encryption example Let the encryption function be
f (a) = (3a + 9) mod 26 Encrypt “Stop Thief” STOP THIEF (capitals) 19,20,15, ,8,9,5,6 14,17,2,5 17,7,10,24,1 NQBE QGJXA L9

29 Decryption example Decryption works the same, except that you apply the inverse function. EG: Find the inverse of f (a) = (3a + 9) mod 26 If we didn’t have to deal with mod 26, inverse would be g (a) = 3-1 (a - 9) We’ll see that since gcd(3,26) = 1, the inverse of 3 is actually well defined modulo 26 and is the number 9. This gives: g (a) = 9 (a - 9) mod 26 = (9a – 3) mod 26 L9

30 Review Review 1 : f (x) = (5x + 9) mod 26
Encrypt : “LOGIN UWIKA” Decrypt : “LOGIN UWIKA” Hasil Encrypt : Hasil Decrypt : L9

31 Review 2: Caesar’s Cipher
f (a) = (a+3) mod 26 Pesan / sandi nya sama : TOLONG INFOKAN PASSWORD JARINGAN SERVER ALPHA lakukan proses enkripsi dan dekripsinya. L9

32 RSA Cipher The keys for the RSA algorithm are generated the following way: Choose two distinct prime numbers p and q. Compute n = pq. n is used as the modulus for both the public and private keys. Compute φ(n) = φ(p)φ(q) = (p − 1)(q − 1) = n − (p + q − 1), This value is kept private. Choose an integer e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1; i.e., e and φ(n) are coprime. Determine d as d ≡ e−1 (mod φ(n)); i.e., d is the modular multiplicative inverse of e (modulo φ(n)) This is more clearly stated as: solve for d given d⋅e ≡ 1 (mod φ(n)) e is released as the public key exponent. d is kept as the private key exponent. L9

33 RSA Cipher Choose p = 3 and q = 11 Compute n = p * q = 3 * 11 = 33
Choose e such that 1 < e < φ(n) and e and n are coprime. Let e = 7 Compute a value for d such that (d * e) % φ(n) = 1. One solution is d = 3 [(3 * 7) % 20 = 1] Public key is (e, n) => (7, 33) Private key is (d, n) => (3, 33) The encryption of m = 2 is c = 27 % 33 = 29 The decryption of c = 29 is m = 293 % 33 = 2 L9

34 Review 3: RSA f (a) = (a+3) mod 26 Pesan : BCA (231)
lakukan proses enkripsi dengan Algoritma RSA dengan mengambil bilangan prima 3 dan 11 serta dipilih bilangan e e = 9 e = 13 Hint : enkripsi satu-2 dari 231 (2 dulu hasilnya enkripsinya ?, kmd 3 dan 1) L9


Download ppt "CMSC Discrete Structures"

Presentasi serupa


Iklan oleh Google