Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Mathematics 4. NUMBER THEORY Lecture 7 Dr.-Ing. Erwin Sitompul

Similar presentations


Presentation on theme: "Discrete Mathematics 4. NUMBER THEORY Lecture 7 Dr.-Ing. Erwin Sitompul"— Presentation transcript:

1 Discrete Mathematics 4. NUMBER THEORY Lecture 7 Dr.-Ing. Erwin Sitompul http://zitompul.wordpress.com

2 7/2 Erwin SitompulDiscrete Mathematics  Integers are whole numbers, without any fractional or decimal components. Example: 8 ; 21 ; 8765 ; –34 ; 0.  They are in opposite to real numbers, which posses decimal components. Example: 8.0 ; 34.25 ; 0.02. Integers

3 7/3 Erwin SitompulDiscrete Mathematics  Suppose a and b are integers, a  0. then a divides b without remaining if there exists an integer c such that b = ac.  Notation: a | b if b = ac, c  Z and a  0. Example: (a)4 | 12 because 12/4 = 3 (integer) or 12 = 4  3. (b)4 | 13 because 13/4 = 3.25 (not integer). Division of Integers

4 7/4 Erwin SitompulDiscrete Mathematics Euclidean Theorem 1: Suppose m and n are integers, n > 0. if m is divided by n then there exists a unique integer q (quotient) and r (remainder), such that m = nq + r where 0  r < n. Example: (a)1987/97= 20, remaining 47 1987= 97  20 + 47 (b)25/7= 3, remaining 4 25= 7  3 + 4 (c)–25/7= –4, remaining 3 –25= 7  (–4) + 3 But not –25 = 7  (–3) – 4, because the remainder will be r = –4, while the condition is 0  r < n) Euclidean Theorem

5 7/5 Erwin SitompulDiscrete Mathematics  Suppose a and b are non-zero integers.  The Greatest Common Divisor (GCD) of a and b is the greatest possible integer d such that d | a and d | b.  In this case, it can be written as GCD(a,b) = d. Example: Determine GCD(45,36) !  Divisors of 45: 1, 3, 5, 9, 15, 45.  Divisors of 36: 1, 2, 3, 4, 6, 9, 12, 18, 36.  Common divisors of 45 and 36 are 1, 3, 9. For the enumeration above, it can be concluded that GCD(45,36) = 9. Greatest Common Divisor (GCD)

6 7/6 Erwin SitompulDiscrete Mathematics Euclidean Theorem 2: Suppose m and n are integer, n > 0, such that m = nq + r, 0  r < n. Then GCD(m,n) = GCD(n,r). Example: Take the value m = 66, n = 18, 66 = 18  3 + 12 then GCD(66,18) = GCD(18,12) = 6 Greatest Common Divisor (GCD)

7 7/7 Erwin SitompulDiscrete Mathematics  The objective This algorithm can be used to find the GCD of two integers.  Inventor Euclid (around 300 BC), a Greek mathematician, wrote the algorithm in his book titled, “Element.” Euclidean Algorithm

8 7/8 Erwin SitompulDiscrete Mathematics If m and n are non-negative integers where m  n, and suppose r 0 = m and r 1 = n. Perform the following divisions in sequence to obtain: r 0 = r 1 q 1 + r 2 0  r 2  r 1, r 1 = r 2 q 2 + r 3 0  r 3  r 2, r i–2 = r i–1 q i–1 + r i 0  r i  r i–1, r i–1 = r i q i + 0 According to Euclidean Theorem 2, GCD(m,n) = GCD(r 0,r 1 ) = GCD(r 1,r 2 ) = … = GCD(r i–2,r i–1 ) = GCD(r i–1,r i ) = GCD(r i,0) = r i Thus, GCD of m and n is the last non-zero remainder of the above sequence of disions, namely r i. … Euclidean Algorithm

9 7/9 Erwin SitompulDiscrete Mathematics Given two non-negative integers m and n (m  n), the following Euclidean Algorithm will find the greatest common divisor of m and n. Euclidean Algorithm 1. If n = 0 then m is the GCD(m,n); STOP. If n  0, proceed to Step 2. 2.Divide m with n and obtain r as the remainder. 3. Replace m with n, and n with r, then loop back to Step 1. Euclidean Algorithm

10 7/10 Erwin SitompulDiscrete Mathematics Example: Take m = 80, n = 12, so the condition that m  n is fulfilled. 80 = 12  6 + 8 12 = 8  1 + 4 8 = 4  2 + 0 n = 0  m = 4 is the last non-zero remainder GCD(80,12) = 4; STOP. Euclidean Algorithm

11 7/11 Erwin SitompulDiscrete Mathematics  GCD(a,b) can be expressed as a linear combination of a and b with the multiplying coefficients that can be freely chosen. Example : GCD(80,12) = 4, then 4 = (–1)  80 + 7  12 Coefficients, can be freely chosen Linear Combination Theorem: Suppose a and b are positive integers, then there exist integers m and n such that GCD(a,b) = ma + nb. Linear Combination

12 7/12 Erwin SitompulDiscrete Mathematics Example: Express GCD(312,70) = 2 as the linear combination of 312 and 70! Solution: Apply Euclidean Algorithm to obtain GCD(312,70) = 2 as follows: 312 = 4  70 + 32(1) 70 = 2  32 + 6(2) 32 = 5  6 + 2(3) 6 = 3  2 + 0(4) Rearrange (3) to 2 = 32 – 5  6(5) Rearrange (2) to 6 = 70 – 2  32(6) Insert (6) to (5) so that 2 = 32 – 5  (70 – 2  32) = 1  32 – 5  70 + 10  32 = 11  32 – 5  70(7) Rearrange (1) to 32 = 312 – 4  70(8) Insert(8) to (7) so that 2 = 11  32 – 5  70 = 11  (312 – 4  70) – 5  70 = 11  312 – 49  70 Thus, GCD(312, 70) = 2 = 11  312 – 49  70 Linear Combination

13 7/13 Erwin SitompulDiscrete Mathematics Modulo Arithmetics Suppose a is an arbitrary integer and m is a positive integer, then a mod m yields the remainder if a is divided by m a mod m = rsuch that a = mq + r, with0  r < m The result of modulo m lies within the set {0,1,2,…,m–1}

14 7/14 Erwin SitompulDiscrete Mathematics Congruence  Take a long on this 38 mod 5 = 3 and 13 mod 5 = 3. then it can be written that 38  13 (mod 5). Pronounced: 38 is congruent with 13 in modulo 5.  Suppose a and b are integers and m > 0. If m divides a – b without remainder, then a  b (mod m).  If a is not congruent with b in modulo m, then it is written as a  b (mod m).

15 7/15 Erwin SitompulDiscrete Mathematics Congruence Example:  17  2 (mod 3)  3 divides 17–2 = 15 without remainder  –7  15 (mod 11)  11 divides –7–15 = –22 without remainder  12  2 (mod 7)  7 cannot divide 12–2 = 10  –7  15 (mod 3)  3 cannot divide –7–15 = –22

16 7/16 Erwin SitompulDiscrete Mathematics Congruence Example :  17  2 (mod 3)  17 = 2 + 5  3  –7  15 (mod 11)  –7 = 15 + (–2)  11 Example :  23 mod 5 = 3  23  3 (mod 5)  6 mod 8 = 6  6  6 (mod 8)  0 mod 12 = 0  0  0 (mod 12)  –41 mod 9 = 4  –41  4 (mod 9)  –39 mod 13 = 0  –39  0 (mod 13) a  b (mod m) can be written as a = b + km (k integer). a mod m = r can also be written as a  r (mod m).

17 7/17 Erwin SitompulDiscrete Mathematics Congruence Theorem: Suppose m is a positive integer. 1.If a  b (mod m) and c is an arbitrary integer, then i. (a + c)  (b + c) (mod m) ii. ac  bc (mod m) iii. a p  b p (mod m), p non-negative 2. If a  b (mod m) and c  d (mod m), then i. (a + c)  (b + d) (mod m) ii. ac  bd (mod m) Congruence

18 7/18 Erwin SitompulDiscrete Mathematics Congruence Example : Suppose 17  2 (mod 3) and 10  4 (mod 3), then according to the Congruence Theorem,  17 + 5  2 + 5 (mod 3)  22  7 (mod 3)  17  5  2  5 (mod 3)  85  10 (mod 3)  17 + 10  2 + 4 (mod 3)  27  6 (mod 3)  17  10  2  4 (mod 3)  170  8 (mod 3)

19 7/19 Erwin SitompulDiscrete Mathematics Prime Numbers  A positive integer p (p > 1) is called a prime number if its divisors are only 1 and p. Example : 23 is a prime number, because it can only be divided by 1 and 23 to get no remainder.  Numbers which are not prime numbers are called composite numbers. Example : 20 is a composite number, because 20 is divisible by 2, 4, 5, and 10, besides by 1 and 20 itself.

20 7/20 Erwin SitompulDiscrete Mathematics Two integers a and b are said to be relatively prime if they do not have any common factors other than 1, or, GCD(a,b) = 1. Relative Primes If a and b are relatively prime, then there exist integers m and n such that ma + nb = 1. Example :  20 and 3 are relatively prime, since GCD(20,3) = 1.  7 and 11 are relatively prime, since GCD(7,11) = 1.  20 and 5 are not relatively prime, since GCD(20,5) = 5 ≠ 1. Example :  20 and 3 are relatively prime because GCD(20,3) =1, so that it can be written that 2  20 + (–13)  3 = 1 (m = 2, n = –13).  20 and 5 are not relatively prime because GCD(20,5) ≠ 1, and thus 20 and 5 cannot be written in the form of m  20 + n  5 = 1.

21 7/21 Erwin SitompulDiscrete Mathematics Inverse of Modulo  In real number arithmetics, the inverse of multiplication is division.  As example, the inverse of 4 is 1/4, because 4  1/4 = 1.  In modulo arithmetics, finding the inverse is somehow more difficult.  If a and m are relatively prime and m > 1, then there exists the inverse of “a modulo m”.  The inverse of “a modulo m” is an integer x such that ax  1 (mod m).

22 7/22 Erwin SitompulDiscrete Mathematics Inverse of Modulo Example : Determine the inverse of 4 (mod 9) ! Solution: Because GCD(4,9) = 1, then the inverse of 4 (mod 9) exists. From the Euclidean Algorithm, 9 = 2  4 + 1. Rearrange the above equation to –2  4 + 1  9 = 1. From the last equation, it can be obtained that –2 is the inverse of 4 (mod 9).  Check that –2  4  1 (mod 9)

23 7/23 Erwin SitompulDiscrete Mathematics Inverse of Modulo Remark: Every integer which is congruent with –2 (mod 9) is also the inverse of 4. Example :  7  –2 (mod 9)  9 divides 7 – (–2) = 9 without remainder  –11  –2 (mod 9)  9 divides –11 – (–2) = –9 without remainder  16  –2 (mod 9)  9 divides 16 – (–2) = 18 without remainder

24 7/24 Erwin SitompulDiscrete Mathematics Example : Determine the inverse of 17 (mod 7) ! Solution: Since GCD(17,7) = 1, then the inverse of 17 (mod 7) exists. From the Euclidean Algorithm, 17 = 2  7 + 3(1) 7 = 2  3 + 1 (2) 3 = 3  1 + 0 (3) Rearrange (2) to 1 = 7 – 2  3 (4) Rearrange (1) to 3 = 17 – 2  7(5) Insert (5) to (4) 1 = 7 – 2  (17 – 2  7) 1 = –2  17 + 5  7 Inverse of Modulo From the last equation, –2 is the inverse of 17 (mod 7).  Checking, –2  17  1 (mod 7)

25 7/25 Erwin SitompulDiscrete Mathematics Example : Determine the inverse of 18 (mod 10) ! Solution: Since GCD(18,10) = 2 ≠ 1, then the inverse of 17 (mod 7) does not exist. Inverse of Modulo

26 7/26 Erwin SitompulDiscrete Mathematics Linear Congruence The linear congruence is in the form of : ax  b (mod m), where m > 0, a and b are arbitrary integers, and x is any integer. The solution can be found in the way: ax = b + km  x = (b + km) / a Try each value of k = 0, 1, 2, … and k = –1, –2, … that delivers integer value for x.

27 7/27 Erwin SitompulDiscrete Mathematics Linear Congruence Example : Determine the solutions for 4x  3 (mod 9) ! Solution: 4x  3 (mod 9)  x = (3 + k  9 ) / 4 k = 0  x = (3 + 0  9) / 4 = 3/4  not a solution k = 1  x = (3 + 1  9) / 4 = 3  a solution k = 2  x = (3 + 2  9) / 4 = 21/4  not a solution k = 3, k = 4  no solution k = 5  x = (3 + 5  9) / 4 = 12  a solution … k = –1  x = (3 – 1  9) / 4 = –6/4  not a solution k = –2  x = (3 – 2  9) / 4 = –15/4  not a solution k = –3  x = (3 – 3  9) / 4 = –6  a solution … k = –7  x = (3 – 7  9) / 4 = –15  a solution … The set of solutions is: {3, 12, …, –6, –15, …}.

28 7/28 Erwin SitompulDiscrete Mathematics Example : Determine the solutions for 2x  3 (mod 4) ! Solution: 2x  3 (mod 4)  x = (3 + k  4 ) / 2  Because k  4 is always an even number, then 3 + k  4 will always be an odd number.  If an odd number is divided by 2, then the result will be a decimal number (never be an integer).  Thus, there is no value of x that can be the solution of 2x  3 (mod 4). Linear Congruence

29 7/29 Erwin SitompulDiscrete Mathematics Linear Congruence Example : Find x such that 3x  4 (mod 7) ! Solution: 3x  4 (mod 7) (3) –1  3x  (3) –1  4 (mod 7) x  (3) –1  4 (mod 7) x  –2  4 (mod 7) x  –8 (mod 7) x  6 (mod 7) x={..., –8, –1, 6, 13, 19,...}

30 7/30 Erwin SitompulDiscrete Mathematics Application: ISBN  ISBN (International Standard Book Number)  ISBN consists of 10 characters, commonly separated by space or minus sign, i.e., 0–3015–4561–9.  ISBN is classified into several codes:  Code to identify the language of the book  Code to identify the publisher  Code that uniquely assigned for the book (i.e. titles)  Checksum character or check digit (can be a number of or alphabet X)

31 7/31 Erwin SitompulDiscrete Mathematics  The check digit is so chosen that Application: ISBN Example : ISBN 0–3015–4561–8 0: Code for English-language country group using, 3015: Publisher code 4561: Item number, title of the book 8 : Check digit. The check digit is obtained as follows: 1  0 + 2  3 + 3  0 + 4  1 + 5  5 + 6  4 + 7  5 + 8  6 + 9  1 = 151 Therefore, the check digit is 151 mod 11 = 8.

32 7/32 Erwin SitompulDiscrete Mathematics Example : ISBN 978-3-8322-4066-0  Since January 2007, ISBN contains 13 digits.  The way to count the check digit is different. It uses modulo 10. The check digit will be obtained as follows: 9  1 + 7  3 + 8  1 + 3  3 + 8  1 + 3  3 + 2  1 + 2  3 + 4  1 + 0  3 + 6  1 + 6  3 = 100 Thus, the check digit is 100 + x 13  0 (mod 10) x 13 = 0 Application: ISBN  How to check the validity of a credit card number?

33 7/33 Erwin SitompulDiscrete Mathematics Homework 7 Determine GCD(216,88) and express the GCD as a linear combination of 216 and 88. No.1: No.2: Given the ISBN-13: 978-0385510455, check whether the code is valid or not. Hint: Verify the check digit of the ISBN numbers.

34 7/34 Erwin SitompulDiscrete Mathematics Homework 7 New Determine the solutions for 5x  7 (mod 11) ! No.1: No.2: Given the ISBN-10: 0072880082, check whether the code is valid or not. Hint: Verify the check digit of the ISBN numbers. No.3: Voluntary for additional 20 points The ISBN-13: 978-007289A054 is valid. What will be the value of A?


Download ppt "Discrete Mathematics 4. NUMBER THEORY Lecture 7 Dr.-Ing. Erwin Sitompul"

Similar presentations


Ads by Google