1 / 9

CS 285- Discrete Mathematics

CS 285- Discrete Mathematics. Lecture 10 . Section 3.4 The Integers & Division. Division Division Theorem Modular Arithmetic Applications of Congruences. Division.

dori
Download Presentation

CS 285- Discrete Mathematics

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. CS 285- Discrete Mathematics Lecture 10

  2. Section 3.4 The Integers & Division • Division • Division Theorem • Modular Arithmetic • Applications of Congruences Integers &Division

  3. Division • Definition: If a and b are integers with a ≠ 0, then it is said that a divides b if there is an integer c such that b =ac. • If a divides b, then a is a factor of b and that b is a multiple of a. • Notation: a | b denotes that a divides b. When a doesn’t divide b then, a b • Ex. Determine whether 3 | 7 and whether 3 | 12. Integers &Division

  4. Division Theorems • Let a, b, c be integers. Then • If a | b and a | c, then a | (b +c) • If a | b, then a |bc for all integers c • If a | b and b | c, then a | c • If a | b and a | c, then a | mb + nc (where n & m are integers). Integers &Division

  5. The Division Algorithm • Definition: for an integer a and a positive integer d, there are unique integers q and r with 0 ≤ r < d, such that a = dq +r • Notation: q = a div d, r = a mod d, where • a is the dividend, d is the divisor,q is the quotient, and r is the remainder. • Ex. What is the quotient and remainder when 101 is divided by 11. 101 = 11 * 9 + 2 Hence the quotient is 101 div 11 = 9, and remainder is 101 mod 11 = 2 Integers &Division

  6. Modular Arithmetic • If a and b are integers, and let m be a positive integer. Then a ≡ b (mod m) if and only if a mod m ≡ b (mod m). thus m divides a – b. • 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. • 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) then 18 = 7 + 11 = 2 + 1 = 3 (mod 5) 77 = 7 * 11 = 2 * 1 = 2 (mod 5) Integers &Division

  7. Modular arithmetic (Cont.) • Let m be a positive integer. And let a and b be integers. Then ( a + b) mod m = ((a mod m) + (b mod m)) mod m ab mod m = ((a mod m)(b mod m)) mod m Ex. (3 + 5)= 8 mod 2 =0 = ((3 mod 2) + ( 5 mod 2 ) ) mod 2 = ( 1 + 1 ) mod 2 = 0 Integers &Division

  8. Hashing function • H(k) = k mod m, where k and m are positive integers. • Hashing is used to assign available memory locations for saving files. • Ex. Let m = 111 • H(06212848) = 06212848 mod 111 = 14 • H(037149212)=037149212 mod 111 = 65 Integers &Division

  9. Pseudorandom Numbers • Randomly chosen numbers are generated by using the congruence xn+1 = (ax0 + c) mod m Where the four integers are: the modulus m, the multiplier a, increment c and the seed x0 Ex. m = 9, a =7, c = 4 and x0 = 3 x1 = 7x0 + 4 mod 9 = 21 + 4 mod 9 = 25 mod 9 = 7 x2 = 7x1 + 4 mod 9 = 49 + 4 mod 9 = 53 mod 9 = 8 x3 = 7x2 + 4 mod 9 = 56 + 4 mod 9 = 60 mod 9 = 6 x4 = 7x3 + 4 mod 9 = 42 + 4 mod 9 = 46 mod 9 = 1 Thus the sequence generated is : 3, 7, 8, 6, 1, ….. Integers &Division

More Related