1 / 29

The Integers and Division

The Integers and Division. We will review the basic concept of number theory. Division Modular Arithmetic. Division. Definition: If a and b are integers with a ≠ 0,we say that a divides b if there is an integer c such that b = a c.

Download Presentation

The Integers and Division

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Integers and Division We will review the basic concept of number theory • Division • Modular Arithmetic.

  2. Division Definition: If a and b are integers with a ≠ 0,we say that a divides b if there is an integer c such that b = a c. • In this case (when a divides b), we say that: • a is a factor of b. • b is multiple of a. • b is dividable by a. We use the notations (when a divides b): a | b (a divides b) a ∤ b (a does not divide b)

  3. Example : Determine whether 3 | 7 and whether 3 | 12. • For 3 | 7: • 3 divides 7 if 7= c* 3 What is the value of c? • if c=1 7 = 1 *3=3 (invalid) • if c=2 7 = 2 *3= 6 (invalid) • if c=3 7 = 3 *3=9 (invalid) • Therefore, 3 ∤ 7 (3 does not divides 7), because 7/3 is not an integer. • For 3 | 12: • 3 divides 12 if 12= c* 3 What is the value of c? • we can take c=4 (12= 4 * 3) • Therefore, 3 | 12

  4. Home work # 1: Does 17 divide each of these numbers? • 68 • 84 • 357 • 1001 You can send the home work to the following address: a.khedr@uoh.edu.sa You must write the following: (1) Name (2) ID (3) Course code

  5. Theorem: 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 = d q + r. • In this case, we called that: • d is the divisor • a is the dividend • q is the quotient and equals q = a div d. • r is the reminder and equals r = a mod d.

  6. Example : Given a = 7 and d= 3. Find the quotient and reminder. a = d q +r 7 = 3 q + r q=2 and r =1 7= 3 ∙ 2 + 1 Remarks: q=2 is a unique integer. Can you put another value for q? r =1 satisfies 0 ≤ r < d. 7 Div 3= 2 7 Mod 3=1

  7. Example : what are the quotient and reminder when -11 is divided by 3? Sol: a = -11 and d= 3 a = q ∙ d +r and 0 ≤ r < d=3 -11= q ∙ 3 + r q= -4 r= 1 Invalid solution Remark : in the above example a= -11 and d= 3 If we put q=-3 then -11= (-3) ∙ 3 + r Therefore, r= -2 Because r must satisfies 0 ≤ r < d=3 Remark: the reminder cannot be negative.

  8. Modular arithmetic Definition: 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. We use the notations : a≡b (mod m) (a is congruent to b modulo m) a≢b (mod m) (a and b are not congruent to modulo m)

  9. Example : Determine whether 17 is congruent to 5 modulo 6. Sol: a=17, b=5 and m=6 We want to prove m divides a-b a-b= 17-5=12 m =6 divides a-b=12 17 ≡ 5 (mod 6). Example : Determine whether 24 is congruent to 14 modulo 6.

  10. Application: Pseudorandom Numbers Randomly chosen numbers are often needed for computer simulations. The most commonly used procedure for generating pseudorandom numbers is the linear congruential method.

  11. Application: Pseudorandom Numbers • Congruential Method: • Choose four integers: • modulus m • multiplier a • increment c • seed x0. • where 2 ≤ a < m, 0 ≤ c < m, and 0 ≤ x0 < m. • (2) We generate the sequence of pseudorandom {xn}, with 0 ≤ x0 < m for all n by successively using the congruence • xn+1 = (axn + c) mod m

  12. Example: Generate the sequence of pseudorandom numbers by choosing m = 9, a = 7, c =4, and x0= 3. • Solution: by using xn+1 = (axn + c) mod m • n=0: x1 = (a x0 + c) mod 9 • = (7 * 3 + 4) mod 9 • = 25 mod 9 • x1 = 7 • n=1: x2 = (a x1 + c) mod 9 • = (7 * 7 + 4) mod 9 • = 53 mod 9 • x2 = 8 • n=2: x3 = (a x2 + c) mod 9 • = (7 * 8 + 4) mod 9 • = 60 mod 9 • x3 = 6

  13. Solution: by using xn+1 = (axn + c) mod m

  14. Application: Cryptology • One of the important applications of congruence is cryptology. • Cryptology is the study of secret messages. • Shift Cipher Method: • Main idea: the letter represented by integer p is replaced with the letter represented by (p+k) mod 26 and k is an integer. • Replace each letter by an integer from 0 to 25, based on its position in the alphabet.

  15. Application: Cryptology (2) Apply the function, f, on the integer p as follows: f(p) = (p+k) mod 26 Example: if p =3 and k=3 then f(p =3)= (3+3) mod 26 = 6 if p =24 and k=3 then f(p=24)= (24+3) mod 26 = 1 (3) Translate the integer to letter according to previous table of alphabetic.

  16. Example: Use Caesar’s method to encrypt the following message “MEET YOU IN THE PARK”. • Solution: • (1) Replace the letters in the message with the numbers as follows: • (2) Replace each number , p, by f(p)= (p+3) mod 26.

  17. (3) Translate the integers to letters as follows: Therefore, the produce encrypted message is “PHHW BRX LQ WKH SDUN”

  18. Decryption # To recover the original message from a secret message encrypted by shift cipher, we use the function f -1(the inverse of f). f -1(p)=(p-k) mod 26 This means that : to find an original message, each letter is shifted back k letters in the alphabet. # In case of k=3 (caesar cipher), each letter is shifted back 3 letters in the alphabet. f -1(p)=(p-3) mod 26

  19. Example: Use Caesar’s method to decrypt the following message “PHHW BRX LQ WKH SDUN”. • Solution: • (1) Replace the letters in the message with the numbers as follows: • (2) Replace each number , p, by f -1(p)= (p-3) mod 26.

  20. (3) Translate the integers to letters as follows: Therefore, the produce decrypted message is “Meet you in the park”

  21. Another encryption method is . Affine transformation: Main idea: the letter represented by integer p is replaced with the letter represented by (a p+b) mod 26 and a and b are integers.

  22. Example: Encrypt the following message “” WELCOME TO HAIL” using f(p)= (3 p+7) mod 26 • Solution: • (1) Replace the letters in the message with the numbers as follows: • (2) Replace each number , p, by f(p)= (3 p +7) mod 26.

  23. (3) Translate the integers to letters as follows: Therefore, the produce encrypted message is “ VTONXRT MX CHFO ”

  24. Application: Hashing Functions One of the important applications of congruence is assign memory locations to computer files. How can memory locations be assigned so that customer records can be retrieved quickly? Hashing Function: Main idea: a hashing function h assigns memory location h(k) to record that has k as its key. h(k)= k mod m Where m is the number of available memory locations.

  25. Example: assume that m=11 and the k=064212848. Then H(064212848)=064212848 mod 11=7

  26. Homework on Integers and Division

  27. (1) Does 17 divide each of these numbers? • 68 b) 84 c) 357 d) 1001 (2) What are the quotient and reminder when a) 19 is divided by 77 ? b) -111 is divided by 11? c) -1 is divided by 3? d) 4 is divided by 1? (3) Evaluate these quantities a) -17 mod 2 b) 144 mod 7 c) -94 mod 11 d) 155 mod 19 (4) Decide whether each of these integers is congruent to 5 modulo 17? a) 80 b) 103 c) -29 d) -122

  28. (5) What sequence of pseudorandom numbers is generated using linear congruential number generator xn+1= 3 xn mod 11 with seed x0=2? (6) What sequence of pseudorandom numbers is generated using linear congruential number generator xn+1= (4 xn +1) mod 7 with seed x0=3? (7) Encrypt the message “Do NOT PASS GO” by using the following encryption functions: a) f(p) = (p+3) mod 26 (The Caesar cipher) b) f(p) = (p+13) mod 26 c) f(p) = (3p+7) mod 26 (8) Decrypt these messages using f -1(p)= (p-3) mod 26 a) EOXH MHDQV b) WHVW WRGDB c) HDW GLP VXP

More Related