Euclidean Algorithm How to find a greatest common divisor in several easy steps.

Slides:



Advertisements
Similar presentations
GREATEST COMMON FACTOR
Advertisements

Partial Quotients Division Algorithm. Quick Slate Review Solve the following problems. ……. Ready……… …………..Set………….. ………Go!
Section 4.1: Primes, Factorization, and the Euclidean Algorithm Practice HW (not to hand in) From Barr Text p. 160 # 6, 7, 8, 11, 12, 13.
CSE115/ENGR160 Discrete Mathematics 03/15/12
Decimals and Fractions
Section 5-4 Greatest Common Factor and Least Common Multiple.
Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
Basic properties of the integers
Fractions Review.
CSC2110 Discrete Mathematics Tutorial 5 GCD and Modular Arithmetic
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
CSE115/ENGR160 Discrete Mathematics 03/17/11 Ming-Hsuan Yang UC Merced 1.
Discrete Structures Chapter 2 Part B Mathematical Induction
Proofs, Recursion, and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
By Jennifer Adams. The traditional approach (or algorithm) for large number division is the most abstract and difficult approach to division. Yet many.
Everyday Mathematics Partial-Quotients Division Partial-Quotients Division Partial-quotients is a simpler way to do long division. Many children like.
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Chapter 5 Number Theory © 2008 Pearson Addison-Wesley.
BY MISS FARAH ADIBAH ADNAN IMK
Quiz 2 key.
Divisibility October 8, Divisibility If a and b are integers and a  0, then the statement that a divides b means that there is an integer c such.
CSCI 1900 Discrete Structures
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
9/2/2015Discrete Structures1 Let us get into… Number Theory.
Section 2.2: Affine Ciphers; More Modular Arithmetic Practice HW (not to hand in) From Barr Textbook p. 80 # 2a, 3e, 3f, 4, 5a, 7, 8 9, 10 (Use affinecipherbreaker.
Mathematics of Cryptography Part I: Modular Arithmetic
February 24, 2015Applied Discrete Mathematics Week 4: Number Theory 1 Modular Arithmetic Let a be an integer and m be a positive integer. We denote by.
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
Multi-digit Numerical Long Division 1 © 2013 Meredith S. Moody.
Copyright © Cengage Learning. All rights reserved. CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF.
Operations with Fractions REVIEW CONCEPTS. Fractions A number in the form Numerator Denominator Or N D.
WIKIPEDIA HAS MANY MORE DIVISIBILITY RULES. EXAMPLE Since 52=13(4) is divisible by 4, is divisible by 4 Since 452=56(8)+4 is not divisible.
The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.
Repeated Subtraction: Division
5.6 Dividing Polynomials.
Teaching Division to Elementary Students
Algebra Problems… Solutions Algebra Problems… Solutions © 2007 Herbert I. Gross Set 10 By Herbert I. Gross and Richard A. Medeiros next.
Multiplication and Division of Fractions Thursday, June 18, 2015.
Copyright © 2009 Pearson Education, Inc. Chapter 5 Section 1 - Slide 1 Chapter 1 Number Theory and the Real Number System.
MAT 320 Spring 2008 Section 1.2.  Start with two integers for which you want to find the GCD. Apply the division algorithm, dividing the smaller number.
Prime Factorization SWBAT find the prime factorization of a composite number.
Section 2.2: Affine Ciphers; More Modular Arithmetic Shift ciphers use an additive key. To increase security, we can add a multiplicative parameter. –For.
Algorithms 1.Notion of an algorithm 2.Properties of an algorithm 3.The GCD algorithm 4.Correctness of the GCD algorithm 5.Termination of the GCD algorithm.
Warm-Up. TEST Our Ch. 9 Test will be on 5/29/14 Complex Number Operations.
Dividing Decimals by a Whole Number 3.6 ÷ 3.
Partial Quotients.
Partial Quotient Method In this division algorithm the children record on the right side of the problem. The first thing they do is divide. They ask themselves.
Math 409/409G History of Mathematics Books VII – IX of the Elements Part 1: Divisibility.
Tuesday’s lecture: Today’s lecture: One-way permutations (OWPs)
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
The Steps… 1.Divide2. Multiply 3. Subtract4. Bring Down And an easy way to remember them… D ad M om S ister B rother.
The Euclidean Algorithm That’s right, it’s real..
Ref: Pfleeger96, Ch.31 Properties of Arithmetic Reference: Pfleeger, Charles P., Security in Computing, 2nd Edition, Prentice Hall, 1996.
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Lecture 4 The Euclidean Algorithm
CSCI 3333 Data Structures Recursion Exercises
CSE15 Discrete Mathematics 03/20/17
Partial Quotients Division Algorithm
Applied Discrete Mathematics Week 4: Number Theory
Standard Algorithm By: Ally, Zoey, and Maha.
Repetition and Loop Statements
Chapter 5 Number Theory 2012 Pearson Education, Inc.
Chapter 5 Number Theory 2012 Pearson Education, Inc.
Everyday Mathematics Partial-Quotients Division
Everyday Mathematics Partial-Quotients Division
Applied Discrete Mathematics Week 10: Introduction to Counting
Miniconference on the Mathematics of Computation
Presentation transcript:

Euclidean Algorithm How to find a greatest common divisor in several easy steps

Euclidean Algorithm The well known Euclidean algorithm finds the greatest common divisor of two numbers using only elementary mathematical operations - division and subtraction

Euclidean Algorithm A divisor of a number a is an integer that divides it without remainder For example the divisors of 12 are 1, 2, 3, 4, 6 and 12 The divisors of 18 are 1, 2, 3, 6, 9 and 18.

Euclidean Algorithm The greatest common divisor, or GCD, of two numbers is the largest divisor that is common to both of them. For example GCD(12, 18) is the largest of the divisors common to both 12 and 18.

Euclidean Algorithm The common divisors of 12 and 18 are 1, 2, 3 and 6. Hence GCD(12, 18)=6.

Euclidean Algorithm The Euclidean Algorithm to find GCD(a, b) relies upon replacing one of a or b with the remainder after division. Thus the numbers we seek the GCD of are steadily becoming smaller and smaller. We stop when one of them becomes 0.

Euclidean Algorithm Specifically, we assume that a is larger than b. If b is larger than a, then we swap them around so that a becomes the old b and b becomes the old a. We then look for numbers q and r so that a=bq+r. They must have the properties that q  0 and 0  r<b. In other words, we seek the largest such q.

Euclidean Algorithm As examples, consider the following. a=12, b=5; 12=5*2+2 so q=2, r=2 a=24, b=18; 24=18*1+6 so q=1, r=6 a=30, b=15; 30=15*2+0 so q=2, r=0 a=27, b=14; 27=14*1+13 so q=1, r=13 Try the ones on the next slide.

Euclidean Algorithm Find q and r for the following sets of a and b. The answers are on the next slide. a=28, b=12 a=50, b=30 a=35, b=14 a=100, b=20

Euclidean Algorithm Answers q=2, r=4 q=1, r=20 q=2, r=7 q=5, r=0

Euclidean Algorithm The algorithm works in the following way. Given a and b, we find numbers q and r so that a=bq+r. We make sure that q is as large as possible (≥0), and 0≤r<b. For example, if a=18, b=12, then we write 18=12*1+6.

Euclidean Algorithm Actually the number q isn’t important, it is just easier to find r with it when solving problems by hand. Most software can find the remainder r without finding q. For example the Java statement below will find r. r=a%b;

Euclidean Algorithm Once the remainder r has been found we replace a by b and b by r. This relies on the fact that GCD(a,b)=GCD(b,r). Hence we repeatedly find r, the remainder after a is divided by b. Then replace a by b and b by r, and keep on in this way until r=0.

Euclidean Algorithm Let us look at a graphical interpretation of the Euclidean algorithm. Obviously if p=GCD(a,b) then p|a and p|b, that is to say p divides both a and b evenly with no remainder.

Euclidean Algorithm Suppose a and b are represented by the lengths below.

Euclidean Algorithm Note that b does not go into a evenly, but has some small remainder.

Euclidean Algorithm If p is the GCD of a and b then it divides evenly into both a and b. Hence it divides evenly into b and thus must divide evenly into both of the larger two boxes in the previous diagram.

Euclidean Algorithm Then p divides the length representing b a whole number of times, and hence the boxes in a that represent whole lengths of b.

Euclidean Algorithm Of course if p divides a evenly then it must also divide the remainder evenly. The picture below shows this.

Euclidean Algorithm Hopefully it will be clear that by now any number that divides both a and b must also divide the remainder r. The largest of these will of course be the GCD of a and b. So GCD(a,b)=GCD(b,r).