b11 1 divisibility
play

B11.1 Divisibility Can we equally share n muffins among m persons - PowerPoint PPT Presentation

Discrete Mathematics in Computer Science October 28, 2020 B11. Divisibility & Modular Arithmetic Discrete Mathematics in Computer Science B11. Divisibility & Modular Arithmetic B11.1 Divisibility Malte Helmert, Gabriele R oger


  1. Discrete Mathematics in Computer Science October 28, 2020 — B11. Divisibility & Modular Arithmetic Discrete Mathematics in Computer Science B11. Divisibility & Modular Arithmetic B11.1 Divisibility Malte Helmert, Gabriele R¨ oger B11.2 Modular Arithmetic University of Basel October 28, 2020 Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 1 / 21 Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 2 / 21 B11. Divisibility & Modular Arithmetic Divisibility B11. Divisibility & Modular Arithmetic Divisibility Divisibility B11.1 Divisibility ◮ Can we equally share n muffins among m persons without cutting a muffin? ◮ If yes then n is a multiple of m and m divides n . ◮ We consider a generalization of this concept to the integers. Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 3 / 21 Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 4 / 21

  2. B11. Divisibility & Modular Arithmetic Divisibility B11. Divisibility & Modular Arithmetic Divisibility Divisibility Divisibility and Linear Combinations Theorem (Linear combinations) Definition (divisor, multiple) Let a , b and d be integers. If d | a and d | b then Let m , n ∈ Z . If there exists a k ∈ Z such that mk = n , for all integers x and y it holds that d | xa + yb. we say that m divides n , m is a divisor of n or n is a multiple of m and write this as m | n . Proof. If d | a and d | b then there are k , k ′ ∈ Z such that kd = a and k ′ d = b . Which of the following are true? It holds that xa + yb = xkd + yk ′ d = ( xk + yk ′ ) d . ◮ 2 | 4 As x , y , k , k ′ are integers, xk + yk ′ is integer, thus d | xa + yb . ◮ − 2 | 4 Some consequences: ◮ 2 | − 4 ◮ d | a − b iff d | b − a ◮ 4 | 2 ◮ If d | a and d | b then d | a + b and d | a − b . ◮ 3 | 4 ◮ If d | a then d | − 8 a . Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 5 / 21 Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 6 / 21 B11. Divisibility & Modular Arithmetic Divisibility B11. Divisibility & Modular Arithmetic Divisibility Multiplication and Exponentiation Partial Order If we consider only the natural numbers, divisibility is a partial order: Theorem Theorem Let a , b , c ∈ Z and n ∈ N > 0 . Divisibility | over N 0 is a partial order. If a | b then ac | bc and a n | b n . Proof. Proof. ◮ reflexivity: For all m ∈ N 0 it holds that m · 1 = m , so m | m . If a | b there is a k ∈ Z such that ak = b . ◮ transitivity: If m | n and n | o there are k , k ′ ∈ Z Multiplying both sides with c , we get cak = cb and thus ca | cb . such that mk = n and nk ′ = o . From ak = b , we also get b n = ( ak ) n = a n k n , so a n | b n . With k ′′ = kk ′ it holds then that o = nk ′ = mkk ′ = mk ′′ , and consequently m | o . . . . Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 7 / 21 Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 8 / 21

  3. B11. Divisibility & Modular Arithmetic Divisibility B11. Divisibility & Modular Arithmetic Modular Arithmetic Partial Order Proof (continued). ◮ antisymmetry: We show that if m | n and n | m then m = n . If m = n = 0, there is nothing to show. Otherwise, at least one of m and n is positive. B11.2 Modular Arithmetic Let this w.l.o.g. (without loss of generality) be m . If m | n and n | m then there are k , k ′ ∈ Z such that mk = n and nk ′ = m . Combining these, we get m = nk ′ = mkk ′ , which implies (with m � = 0) that kk ′ = 1. Since k and k ′ are integers, this implies k = k ′ = 1 or k = k ′ = − 1. As mk = n , m is positive and n is non-negative, we can conclude that k = 1 and m = n . Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 9 / 21 Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 10 / 21 B11. Divisibility & Modular Arithmetic Modular Arithmetic B11. Divisibility & Modular Arithmetic Modular Arithmetic Halloween is Coming Euclid’s Division Lemma Theorem (Euclid’s division lemma) For all integers a and b with b � = 0 ◮ You have m sweets. there are unique integers q and r ◮ There are k kids showing up for with a = qb + r and 0 ≤ r < | b | . trick-or-treating. Number q is called the quotient and r the remainder. ◮ To keep everything fair, every kid Without proof. gets the same amount of treats. ◮ You may enjoy the rest. :-) Examples: ◮ How much does every kid get, ◮ a = 18 , b = 5 how much do you get? ◮ a = 5 , b = 18 ◮ a = − 18 , b = 5 ◮ a = 18 , b = − 5 Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 11 / 21 Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 12 / 21

  4. B11. Divisibility & Modular Arithmetic Modular Arithmetic B11. Divisibility & Modular Arithmetic Modular Arithmetic Modulo Operation Halloween ◮ With a mod b we refer to the remainder of Euclidean division. ◮ Most programming languages have a built-in operator to compute a mod b (for positive integers): int mod = 34 % 7; // result 6 because 4 * 7 + 6 = 34 def share_sweets(no_kids, no_sweets): ◮ Common application: Determine whether print("Each kid gets", a natural number n is even. no_sweets // no_kids, n % 2 == 0 "of the sweets.") ◮ Languages behave differently with negative operands! print("You may keep", no_sweets % no_kids, "of the sweets.") Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 13 / 21 Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 14 / 21 B11. Divisibility & Modular Arithmetic Modular Arithmetic B11. Divisibility & Modular Arithmetic Modular Arithmetic Congruence Modulo n Congruence Modulo n – Definition Definition (Congruence modulo n ) For integer n > 1, two integers a and b ◮ We now are no longer interested in the value of the remainder are called congruent modulo n if n | a − b . but will consider numbers a and a ′ as equivalent We write this as a ≡ b (mod n ). if the remainder with division by a given number b is equal. ◮ Consider the clock: Which of the following statements are true? ◮ It’s now 3 o’clock ◮ 0 ≡ 5 (mod 5) ◮ In 12 hours its 3 o’clock ◮ 1 ≡ 6 (mod 5) ◮ Same in 24, 36, 48, . . . hours. ◮ 15:00 and 3:00 are shown the same. ◮ 4 ≡ 14 (mod 5) ◮ In the following, we will express this as 3 ≡ 15 (mod 12) ◮ − 8 ≡ 7 (mod 5) ◮ 2 ≡ − 3 (mod 5) Why is this the same concept as described in the clock example?!? Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 15 / 21 Malte Helmert, Gabriele R¨ oger (University of Basel) Discrete Mathematics in Computer Science October 28, 2020 16 / 21

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend