1 / 11

The Euclidean Algorithm

MAT 320 Spring 2008 Section 1.2. The Euclidean Algorithm. How the Algorithm Works. Start with two integers for which you want to find the GCD. Apply the division algorithm, dividing the smaller number into the larger. Example: a = 320, b = 296. 320 = 296 · 1 + 24

Download Presentation

The Euclidean Algorithm

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. MAT 320 Spring 2008 Section 1.2 The Euclidean Algorithm

  2. How the Algorithm Works • Start with two integers for which you want to find the GCD. Apply the division algorithm, dividing the smaller number into the larger. • Example: a = 320, b = 296. • 320 = 296 · 1 + 24 • The first quotient is q0 and the first remainder is r0.

  3. How the Algorithm Works (cont.) • If you get a remainder of 0, stop. If not, the divisor from the previous step becomes the dividend of the next step. The remainder from the previous step becomes the divisor of the previous step. • 320 = 296 · 1 + 24 • 296 = 24 · 12 + 8 • Continue until you get a remainder of 0.

  4. The Completed Algorithm • 320 = 296 · 1 + 24 • 296 = 24 · 12 + 8 • 24 = 8 · 3 + 0 • We get a remainder of 0, so we stop. The last nonzero remainder is the GCD, so (320, 296) is equal to 8.

  5. Another Example • Compute (346, 592). • 592 = 346 · 1 + 246 • 346 = 246 · 1 + 100 • 246 = 100 · 2 + 46 • 100 = 46 · 2 + 8 • 46 = 8 · 5 + 6 • 8 = 6 · 1 + 2 • 6 = 2 · 3 + 0 • So (346, 592) = 2.

  6. The Euclidean Algorithm and Bézout’s Theorem • We can use the Euclidean Algorithm to find the integers U and V from Bézout’s Theorem. • As an example, let’s use the Euclidean Algorithm to show that (324, 148) = 4. • 324 = 148 · 2 + 28 • 148 = 28 · 5 + 8 • 28 = 8 · 3 + 4 • 8 = 4 · 2 + 0

  7. Finding U and V • We want to find integers U and V such that 4 = 324U + 148V. • Take all of the equations (except the last one) and solve for the remainder. • 28 =324 – 148 · 2 • 8 = 148 – 28 · 5 • 4= 28 – 8 · 3

  8. Back-Substitution • Notice that the last equation expresses 4 as a linear combination of 28 and 8. • 4= 28 · 1 + 8 · (-3) • This is not what we want, however. So we use the previous equation (which has been solved for 8) to substitute.

  9. Back-Substitution (cont.) • 4= 28 · 1 + (148 – 28 · 5) · (-3) • Now we want to rearrange this so that 4 is expressed as a linear combination of 28 and 148 (still not quite what we want, but getting closer) • We get 4 = 28 · 16 + 148 · (-3)

  10. Back-Substitution (cont.) • Now use the previous equation (which has been solved for 28) to substitute. • We get 4 = (324 – 148 · 2) · 16 + 148 · (-3) • Once again, multiply out and rearrange until we get 4 expressed as a linear combination of 324 and 148. • 4 = 324 · 16 + 148 · (-35)

  11. Another Example • Use the Euclidean Algorithm to show that(15, 36) = 3. • Use back-substitution to find integers U and V so that 3 = 15U + 36V.

More Related