Quotient-Remainder Theory, Div and Mod

Slides:



Advertisements
Similar presentations
Discrete Mathematics Lecture 3
Advertisements

Chapter 3 Elementary Number Theory and Methods of Proof.
1 In this lecture  Number Theory ● Rational numbers ● Divisibility  Proofs ● Direct proofs (cont.) ● Common mistakes in proofs ● Disproof by counterexample.
(CSC 102) Lecture 12 Discrete Structures. Previous Lecture Summary Floor and Ceiling Functions Definition of Proof Methods of Proof Direct Proof Disproving.
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides.
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
NUMBER THEORY Chapter 1: The Integers. The Well-Ordering Property.
Number Theory and Cryptography
Elementary Number Theory and Methods of Proof. Basic Definitions An integer n is an even number if there exists an integer k such that n = 2k. An integer.
Chapter II. THE INTEGERS
CMSC 250 Discrete Structures Exam #1 Review. 21 June 2007Exam #1 Review2 Symbols & Definitions for Compound Statements pq p  qp  qp  qp  qp  q 11.
CMSC 250 Discrete Structures Number Theory. 20 June 2007Number Theory2 Exactly one car in the plant has color H( a ) := “ a has color”  x  Cars –H(
Discrete Structures Chapter 2 Part B Mathematical Induction
Proof Must Have Statement of what is to be proven.
1 Indirect Argument: Contradiction and Contraposition.
WHOLE NUMBERS; INTEGERS Whole numbers: Z 0,+ = the natural numbers  {0}. Integers:
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
BY MISS FARAH ADIBAH ADNAN IMK
Homework Review notes Complete Worksheet #2. Homework State whether the conditional sentence is true or false 1.If 1 = 0, then 1 = – 1 True F F T.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 2): The Fundamentals: Algorithms, the.
1 Properties of Integers Objectives At the end of this unit, students should be able to: State the division algorithm Apply the division algorithm Find.
(CSC 102) Discrete Structures Lecture 10.
Mathematics of Cryptography Part I: Modular Arithmetic
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
Number Theory.  A prime number is a natural number greater than 1 that has exactly two factors (or divisors), itself and 1.  Prime numbers less than.
Copyright © Cengage Learning. All rights reserved. CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF ELEMENTARY NUMBER THEORY AND METHODS OF PROOF.
1 Introduction to Abstract Mathematics Chapter 3: Elementary Number Theory and Methods of Proofs Instructor: Hayk Melikya Direct.
Elements of Coding and Encryption Continuation 1.
1 Methods of Proof Proof techniques in this handout –Direct proof –Division into cases –Proof by contradiction In this handout, the proof techniques will.
Fermat’s Little Theorem Fibonacci Numbers Shirley Moore CS4390/5390 Fall September 10,
Chinese Remainder Theorem Dec 29 Picture from ………………………
Number Theory 이재원 School of Information Technology Sungshin W. University.
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
Foundations of Discrete Mathematics Chapter 4 By Dr. Dalia M. Gil, Ph.D.
Week 4 - Monday.  What did we talk about last time?  Divisibility  Quotient-remainder theorem  Proof by cases.
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
Copyright © Cengage Learning. All rights reserved. CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF ELEMENTARY NUMBER THEORY AND METHODS OF PROOF.
Properties of the gcd Theorem: For any two integers a,b there exist integers x,y such that xa + yb = gcd(a,b). A proof will not be given at this point.
Ref: Pfleeger96, Ch.31 Properties of Arithmetic Reference: Pfleeger, Charles P., Security in Computing, 2nd Edition, Prentice Hall, 1996.
1 CMSC 250 Chapter 3, Number Theory. 2 CMSC 250 Introductory number theory l A good proof should have: –a statement of what is to be proven –"Proof:"
Week 4 - Wednesday.  What did we talk about last time?  Divisibility  Proof by cases.
Section 1.7. Definitions A theorem is a statement that can be shown to be true using: definitions other theorems axioms (statements which are given as.
Methods of Proof Lecture 4: Sep 20 (chapter 3 of the book, except 3.5 and 3.8)
Chapter 4 With Question/Answer Animations 1. Chapter Summary Divisibility and Modular Arithmetic - Sec 4.1 – Lecture 16 Integer Representations and Algorithms.
CMSC250 S ECTIONS 0303 & 0304 M IDTERM R EVIEW Sri Kankanahalli Discussion 10: 9 March 2016 Office Hrs: Mon. and Wed. 4-6PM AVW 1112.
Chapter 4 With Question/Answer Animations 1. Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Discrete Mathematics Chapter 2 The Fundamentals : Algorithms, the Integers, and Matrices. 大葉大學 資訊工程系 黃鈴玲.
Agenda Review:  Relation Properties Lecture Content:  Divisor and Prime Number  Binary, Octal, Hexadecimal Review & Exercise.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
Methods of Proof Proof techniques in this handout
Number Theory and Cryptography
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
GCD and Optimization Problem
Analytic Number Theory MTH 435
The Rational Numbers Notes and Examples for 8/15/16
Discrete Math for CS CMPSC 360 LECTURE 4 Last time and recitations:
Direct Proof and Counterexample V: Floor and Ceiling
Direct Proof and Counterexample III
Foundations of Discrete Mathematics
The sum of any two even integers is even.
Methods of Proof Rosen 1.7, 1.8 Lecture 4: Sept 24, 25.
Copyright © Zeph Grunschlag,
Application: Algorithms
Lecture 5 Number Theory & Proof Methods
Discrete Mathematics Chapter 4 Number Theory. Discrete Mathematics Chapter 4 Number Theory.
Sets, Combinatorics, Probability, and Number Theory
Methods of Proof Rosen 1.7, 1.8 Lecture 4: Sept, 2019.
Presentation transcript:

Quotient-Remainder Theory, Div and Mod If 𝑛 and 𝑑 are integers and 𝑑>0, then 𝑛 𝑑𝑖𝑣 𝑑=𝑞 and 𝑛 𝑚𝑜𝑑 𝑑=𝑟 ⟺ 𝑛=𝑑𝑞+𝑟 where 𝑞 and 𝑟 are integers and 0≤𝑟<𝑑. Quotient: q=𝑛 𝑑𝑖𝑣 𝑑= 𝑛 𝑑 Reminder: r=𝑛 𝑚𝑜𝑑 𝑑=𝑛−𝑑𝑞

Exercise Prove that for all integers a and b, if a mod 7 = 5 and b mod 7 = 6 then ab mod 7 = 2. What values are 𝑑, 𝑞, and 𝑟?

Exercise Prove that for all integers a and b, if a mod 7 = 5 and b mod 7 = 6 then ab mod 7 = 2. Hint: 𝑑 = 7 𝑎 = 7𝑚+5, b = 7𝑛+6 𝑎𝑏 = 7𝑚+5 7𝑛+6 =49𝑚𝑛+42𝑚+35𝑛+30=7 7𝑚𝑛+6𝑚+3𝑛+4 +2

Floor & Ceiling Floor: If 𝑥 is a real number and 𝑛 is an integer, then Definition: Floor: If 𝑥 is a real number and 𝑛 is an integer, then 𝑥 =𝑛 ⟺ 𝑛≤𝑥<𝑛+1 Ceiling: if 𝑥 is a real number and 𝑛 is an integer, then 𝑥 =𝑛 ⟺ 𝑛−1<𝑥≤𝑛 𝑥 𝑛 𝑛+1 floor of 𝑥= 𝑥 𝑥 𝑛−1 𝑛 ceiling of 𝑥= 𝑥

Relations between Proof by Contradiction and Proof by Contraposition To prove a statement ∀𝑥 in 𝐷, if 𝑃 𝑥 then 𝑄(𝑥) Proof by contraposition proves the statement by giving a direct proof of the equivalent statement ∀𝑥 in 𝐷, if 𝑄 𝑥 is false then 𝑃 𝑥 is false Proof by contradiction proves the statement by showing that the negation of the statement leads logically to a contradiction. Suppose 𝑥 is an arbitrary element of 𝐷 such that ~𝑄(𝑥) ~𝑃(𝑥) Sequence of steps Suppose ∃𝑥 in 𝐷 such that 𝑃(𝑥) and ~𝑄(𝑥) Same sequence of steps Contradiction: 𝑃(𝑥) and ~𝑃(𝑥)

Summary of Chapter 4 Number theories: Proofs: Even, odd, prime, and composite Rational, divisibility, and quotient-remainder theorem Floor and ceiling The irrationality of 2 and gcd Proofs: Direct proof and counterexample Indirect proof by contradiction and contraposition

𝑟 is rational ⇔ ∃ integers 𝑎 and 𝑏 such that 𝑟 = 𝑎 𝑏 and 𝑏 ≠ 0. The Irrationality of 2 How to proof: Direct proof? Proof by contradiction? Proof by contraposition? If 𝑟 is a real number, then 𝑟 is rational ⇔ ∃ integers 𝑎 and 𝑏 such that 𝑟 = 𝑎 𝑏 and 𝑏 ≠ 0. A real number that is not rational is irrational.

The Irrationality of 2 Proof by contradiction: Starting point: Negation: 2 is rational. To show: A contradiction. 2 = 𝑚 𝑛 , where 𝑚 and 𝑛 are integers with no common factors and 𝑛≠0, by definition of rational. 𝑚 2 = 2 𝑛 2 , by squaring and multiplying both sides with 𝑛 2 𝑚 2 is even, then 𝑚 is even. Let 𝑚 = 2𝑘 for some integer 𝑘. (2𝑘) 2 =4 𝑘 2 =2 𝑛 2 , by substituting 𝑚 = 2𝑘 into 𝑚 2 = 2 𝑛 2 . 𝑛 2 is even, and so 𝑛 is even. Hence both 𝑚 and 𝑛 have a common factor of 2.

Irrationality of 1+3 2 Proof by contradiction: Starting point: Negation: 1+3 2 is rational. To show: A contradiction.

1+3 2 = 𝑎 𝑏 for some integers 𝑎 and 𝑏 with 𝑏≠0. Irrationality of 1+3 2 Proof by contradiction: By definition of rational, 1+3 2 = 𝑎 𝑏 for some integers 𝑎 and 𝑏 with 𝑏≠0. It follows that 3 2 = 𝑎 𝑏 −1 by subtracting 1 from both sides = 𝑎 𝑏 − 𝑏 𝑏 by substitution = 𝑎−𝑏 𝑏 by the rule for subtracting fractions with a common denominator Hence, 2 = 𝑎−𝑏 3𝑏 by dividing both sides by 3. 𝑎 − 𝑏 and 3𝑏 are integers and 3𝑏≠0 by the zero product property. Hence 2 is quotient of the two integers 𝑎 − 𝑏 and 3𝑏 with 3𝑏≠0, so 2 is rational by the definition of rational. This contradicts the fact that 2 is irrational.

Property of a Prime Divisor Proposition 4.7.3 For any integer 𝑎 and any prime number 𝑝, if 𝑝|𝑎 then 𝑝 | (𝑎+1) If a prime number divides an integer, then it does not divide the next successive integer. Starting point: there exists an integer 𝑎 and a prime number 𝑝 such that 𝑝 | 𝑎 and 𝑝 | (𝑎 + 1). To show: a contradiction. 𝑎 = 𝑝𝑟 and 𝑎 + 1 = 𝑝𝑠 for some integers 𝑟 and 𝑠 by definition of divisibility. It follows that 1 = (𝑎 + 1) − 𝑎 = 𝑝𝑠 − 𝑝𝑟 = 𝑝(𝑠 − 𝑟 ), 𝑠 − 𝑟 =1/𝑝, by dividing both sides with 𝑝. 𝑝 > 1 because 𝑝 is prime, hence, 1/𝑝 is not an integer, thus 𝑠−𝑟 is not an integer, which is a contradict 𝑠−𝑟 is an integer since 𝑟 and 𝑠 are integers. if 𝑛 and 𝑑 are integers and 𝑑≠0: 𝑑|𝑛 ⟺ ∃ an integer 𝑘 such that 𝑛=𝑑∙𝑘

Infinitude of the Primes Theorem 4.7.4 Infinitude of the Primes The set of prime numbers is infinite. Proof by contradiction: Starting point: the set of prime number is finite. To show: a contradiction. Assume a prime number 𝑝 is the largest of all the prime numbers 2, 3, 5, 7, 11,. . . ,𝑝. Let 𝑁 be the product of all the prime numbers plus 1: 𝑁 = (2·3·5·7·11· · ·𝑝) + 1 Then 𝑁 > 1, and so, by Theorem 4.3.4 (any integer larger than 1 is divisible by a prime number) , 𝑁 is divisible by some prime number q. Because q is prime, q must equal one of the prime numbers 2, 3, 5, 7, 11, . . . , 𝑝. Thus, by definition of divisibility, 𝑞 divides 2·3·5·7·11· · ·𝑝, and so, by Proposition 4.7.3, 𝑞 does not divide (2·3·5·7·11· · ·𝑝) + 1, which equals 𝑁. Hence N is divisible by q and N is not divisible by q, and we have reached a contradiction. [Therefore, the supposition is false and the theorem is true.]

Greatest Common Divisor (GCD) The greatest common divisor of two integers a and b is the largest integer that divides both 𝑎 and 𝑏. Exercise: gcd 72,63 =9, since 72=9∙8 and 63=9∙7 gcd 10 20 , 6 30 = 2 20 , since 10 20 = 2 20 ∙ 5 20 and 6 30 = 2 30 ∙ 3 30 Definition Let 𝑎 and 𝑏 be integers that are not both zero. The greatest common divisor of 𝑎 and 𝑏, denoted gcd(a, b), is that integer 𝑑 with the following properties: 𝑑 is common divisor of both a and b, in other words, 𝑑 | 𝑎, and 𝑑 | 𝑏. For all integers 𝑐, if 𝑐 is a common divisor of both 𝑎 and 𝑏, then 𝑐 is less than or equal to 𝑑. In other words, for all integers 𝑐, if 𝑐 | 𝑎, and 𝑐 |𝑏, then c≤𝑑.

Greatest Common Divisor (GCD) Lemma 4.8.1 If 𝑟 is a positive integer, then gcd⁡(𝑟,0) = 𝑟. Proof: Suppose 𝑟 is a positive integer. [We must show that the greatest common divisor of both 𝑟 and 0 is 𝑟.] 𝑟 is a common divisor of both 𝑟 and 0 because r divides itself and also 𝑟 divides 0 (since every positive integer divides 0). No integer larger than 𝑟 can be a common divisor of 𝑟 and 0 (since no integer larger than 𝑟 can divide 𝑟). Hence 𝑟 is the greatest common divisor of 𝑟 and 0.

Greatest Common Divisor (GCD) Lemma 4.8.2 If 𝑎 and 𝑏 are any integers not both zero, and if 𝑞 and 𝑟 are any integers such that 𝑎=𝑏𝑞+𝑟, then gcd⁡(𝑎,𝑏)=gcd⁡(𝒃,𝑟) Proof: [The proof is divided into two sections: (1) proof that gcd⁡(𝑎, 𝑏) ≤ gcd⁡(𝑏, 𝑟 ), and (2) proof that gcd⁡(𝑏, 𝑟 ) ≤ gcd⁡(𝑎, 𝑏). Since each gcd is less than or equal to the other, the two must be equal.] gcd⁡(𝒂, 𝒃) ≤ gcd⁡(𝒃, 𝒓): [We will first show that any common divisor of 𝑎 and 𝑏 is also a common divisor of 𝑏 and 𝑟.] Let 𝑎 and 𝑏 be integers, not both zero, and let 𝑐 be a common divisor of 𝑎 and 𝑏. Then 𝑐 | 𝑎 and 𝑐 | 𝑏, and so, by definition of divisibility, 𝑎= 𝑛𝑐 and 𝑏 = 𝑚𝑐, for some integers 𝑛 and 𝑚. Now substitute into the equation 𝑎 = 𝑏𝑞 + 𝑟 to obtain 𝑛𝑐 = (𝑚𝑐)𝑞 + 𝑟.

Greatest Common Divisor (GCD) Lemma 4.8.2 If 𝑎 and 𝑏 are any integers not both zero, and if 𝑞 and 𝑟 are any integers such that 𝑎=𝑏𝑞+𝑟, then gcd⁡(𝑎,𝑏)=gcd⁡(𝒃,𝑟) Proof (cont’): gcd⁡(𝒂, 𝒃) ≤ gcd⁡(𝒃, 𝒓): [We will first show that any common divisor of 𝑎 and 𝑏 is also a common divisor of 𝑏 and 𝑟.] 𝑛𝑐 = (𝑚𝑐)𝑞 + 𝑟. Then solve for 𝑟 : 𝑟 = 𝑛𝑐 − (𝑚𝑐)𝑞 = (𝑛 − 𝑚𝑞)𝑐. But 𝑛 − 𝑚𝑞 is an integer, and so, by definition of divisibility, 𝑐 | 𝑟 . Because we already know that 𝑐 | 𝑏, we can conclude that 𝑐 is a common divisor of 𝑏 and 𝑟 [as was to be shown].

Greatest Common Divisor (GCD) Lemma 4.8.2 If 𝑎 and 𝑏 are any integers not both zero, and if 𝑞 and 𝑟 are any integers such that 𝑎=𝑏𝑞+𝑟, then gcd⁡(𝑎,𝑏)=gcd⁡(𝒃,𝑟) Proof (cont’): gcd⁡(𝒂, 𝒃) ≤ gcd⁡(𝒃, 𝒓): [Next we show that gcd⁡(𝑎, 𝑏) ≤ gcd⁡(𝑏, 𝑟).] By part (a), every common divisor of 𝑎 and 𝑏 is a common divisor of 𝑏 and 𝑟 . It follows that the greatest common divisor of 𝑎 and 𝑏 is defined because 𝑎 and 𝑏 are not both zero, and it is a common divisor of 𝑏 and 𝑟 . But then gcd⁡(𝑎, 𝑏) (being one of the common divisors of 𝑏 and 𝑟) is less than or equal to the greatest common divisor of 𝑏 and 𝑟 : gcd⁡(𝑎, 𝑏) ≤ gcd⁡(𝑏, 𝑟 ). gcd⁡(𝒃, 𝒓) ≤ gcd⁡(𝒂, 𝒃): The second part of the proof is very similar to the first part. It is left as an exercise.

The Euclidean Algorithm Problem: Given two integer A and B with 𝐴>𝐵≥0, find gcd⁡(𝐴,𝐵) Idea: The Euclidean Algorithm uses the division algorithm repeatedly. If B=0, by Lemma 4.8.1 we know gcd⁡(𝐴,𝐵) = 𝐴. If B>0, division algorithm can be used to calculate a quotient 𝑞 and a remainder 𝑟: 𝐴=𝐵𝑞+𝑟 where 0≤𝑟<𝐵 By Lemma 4.8.2, we have gcd⁡(𝐴,𝐵)=gcd⁡(𝐵,𝑟), where 𝐵 and 𝑟 are smaller numbers than 𝐴 and 𝐵. gcd⁡(𝐴, 𝐵) = gcd⁡(𝐵, 𝑟) = ⋯ = gcd⁡(𝑥, 0) = 𝑥 𝑟=𝐴 𝑚𝑜𝑑 𝐵

The Euclidean Algorithm - Exercise Use the Euclidean algorithm to find gcd(330, 156).

The Euclidean Algorithm - Exercise Use the Euclidean algorithm to find gcd(330, 156). Solution: gcd(330,156) = gcd(156, 18) 330 mod 156 = 18 = gcd(18, 12) 156 mod 18 = 12 = gcd(12, 6) 18 mod 12 = 6 = gcd(6, 0) 12 mod 6 = 0 = 6

An alternative to Euclidean Algorithm If 𝑎≥ 𝑏> 0, then gcd⁡(𝑎,𝑏)=gcd⁡(𝑏, 𝑎−𝑏)

An alternative to Euclidean Algorithm If 𝑎≥ 𝑏> 0, then gcd⁡(𝑎,𝑏)=gcd⁡(𝑏, 𝑎−𝑏) Hint: Part 1: proof gcd⁡(𝑎,𝑏)≤gcd⁡(𝑏, 𝑎−𝑏) every common divisor of a and b is a common divisor of b and a-b Part 2: proof gcd⁡(𝑎,𝑏)≥gcd⁡(𝑏, 𝑎−𝑏) every common divisor of b and a-b is a common divisor of a and b.

Homework #5 Problems Converting decimal to rational numbers. 4.2.2: 4.6037 4.2.7: 52.4672167216721…

Homework #5 Problems 1. Converting decimal to rational numbers. 4.2.2: 4.6037 Solution: 4.6037 = 4.6037 10000 ∗10000= 46037 10000 4.2.7: 52.4672167216721… Solution: let X = 52.4672167216721 . . . 100000x = 5246721.67216721…. 10x = 524.67216721… 100000x – 10x = 5246197 X = 5246197 / 99990

Exercise Prove that for any nonnegative integer 𝑛, if the sum of the digits of 𝑛 is divisible by 9, then 𝑛 is divisible by 9. Hint: by the definition of decimal representation 𝑛= 𝑑 𝑘 10 𝑘 + 𝑑 𝑘−1 10 𝑘−1 +⋯+ 𝑑 1 10 1 + 𝑑 0 where 𝑘 is nonnegative integer and all the 𝑑 𝑖 are integers from 0 to 9 inclusive. = 𝑑 𝑘 ( 9999⋯999 𝑘 9 ′ 𝑠 +1)+ 𝑑 𝑘−1 ( 9999⋯999 𝑘−1 9 ′ 𝑠 +1)+⋯+ 𝑑 1 (9+1)+ 𝑑 0 =9 𝑑 𝑘 11⋯11 𝑘 1 ′ 𝑠 + 𝑑 𝑘−1 11⋯11 𝑘−1 1 ′ 𝑠 +⋯+ 𝑑 1 + 𝑑 𝑘 + 𝑑 𝑘−1 +⋯+𝑑 1 + 𝑑 0 = an integer divisible by 9 + the sum of the digits of 𝑛

Homework #5 Problems Theorem: The sum of any two even integers equals 4k for some integer k. “Proof: Suppose m and n are any two even integers. By definition of even, m = 2k for some integer k and n = 2k for some integer k. By substitution, m + n = 2k + 2k = 4k. This is what was to be shown.” What’s the mistakes in this proof?