Today’s Topics: GCD Euclid’s algorithm Extended
Description: Todays Topics: GCD Euclids algorithm Extended Euclids algorithm 2 1. GCD The poor man version of prime factorization 3 GCD Greatest common divisor Given two positive integers a,b, their GCD is the largest integer n such that na and nb
Related Topics
Download Presentation
"Today’s Topics: GCD Euclid’s algorithm Extended" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Presentation Transcript
slide2. Today’s Topics: GCD
Euclid’s algorithm
Extended Euclid’s algorithm 2<br>
slide3. 1. GCD The poor man version of prime factorization 3<br>
slide4. GCD Greatest common divisor
Given two positive integers a,b, their GCD is the largest integer n such that n|a and n|b 4<br>
slide5. GCD What is GCD(20,30)?
5
10
20
30
Other 5<br>
slide6. GCD What is GCD(101281371,347832984723)? 6<br>
slide7. GCD How can we compute GCD(a,b)?
Simple way:
Compute prime factorization of a,b
Take common primes and prime powers
Example: if a=2103859 and b=21735 then GCD(a,b)=21035
However, we believe that computing the prime factorization of large numbers is hard…
Euclid’s algorithm provides a much faster way 7<br>
slide8. 2. Euclid’s algorithm Fast GCD 8<br>
slide9. Euclid’s algorithm<br>
slide10. Euclid’s algorithm (a,b) (b,a mod b)<br>
slide11. Euclid’s algorithm<br>
slide12. Euclid’s algorithm a
20
30
20
10 b
30
20
10
0 Example run: a=20, b=30<br>
slide13. Euclid’s algorithm The same basic questions
Does it always terminate?
Does it return the correct answer?
How fast is it?<br>
slide14. Euclid’s algorithm: termination<br>
slide15. Euclid’s algorithm: termination<br>
slide16. Euclid’s algorithm: termination The value of a keeps decreasing,
which proves termination<br>
slide17. Euclid’s algorithm: correctness g=gcd(a,b)<br>
slide18. Euclid’s algorithm: correctness<br>
slide19. Euclid’s algorithm: correctness<br>
slide20. Euclid’s algorithm: correctness<br>
slide21. Euclid’s algorithm: correctness<br>
slide22. Euclid’s algorithm: correctness g=gcd(a,b) Proved!<br>
slide23. Euclid’s algorithm: speed How many iterations?<br>
slide24. Euclid’s algorithm: speed<br>
slide25. Euclid’s algorithm: speed<br>
slide26. Euclid’s algorithm: speed<br>
slide27. Euclid’s algorithm: speed<br>
slide28. 3. Extended Euclid’s algorithm Using algorithms to do math! 28<br>
slide29. Extended Euclid’s algorithm<br>
slide30. Extended Euclid’s algorithm<br>
slide31. Extended Euclid’s algorithm<br>
Euclid’s algorithm
Extended Euclid’s algorithm 2<br>
slide3. 1. GCD The poor man version of prime factorization 3<br>
slide4. GCD Greatest common divisor
Given two positive integers a,b, their GCD is the largest integer n such that n|a and n|b 4<br>
slide5. GCD What is GCD(20,30)?
5
10
20
30
Other 5<br>
slide6. GCD What is GCD(101281371,347832984723)? 6<br>
slide7. GCD How can we compute GCD(a,b)?
Simple way:
Compute prime factorization of a,b
Take common primes and prime powers
Example: if a=2103859 and b=21735 then GCD(a,b)=21035
However, we believe that computing the prime factorization of large numbers is hard…
Euclid’s algorithm provides a much faster way 7<br>
slide8. 2. Euclid’s algorithm Fast GCD 8<br>
slide9. Euclid’s algorithm<br>
slide10. Euclid’s algorithm (a,b) (b,a mod b)<br>
slide11. Euclid’s algorithm<br>
slide12. Euclid’s algorithm a
20
30
20
10 b
30
20
10
0 Example run: a=20, b=30<br>
slide13. Euclid’s algorithm The same basic questions
Does it always terminate?
Does it return the correct answer?
How fast is it?<br>
slide14. Euclid’s algorithm: termination<br>
slide15. Euclid’s algorithm: termination<br>
slide16. Euclid’s algorithm: termination The value of a keeps decreasing,
which proves termination<br>
slide17. Euclid’s algorithm: correctness g=gcd(a,b)<br>
slide18. Euclid’s algorithm: correctness<br>
slide19. Euclid’s algorithm: correctness<br>
slide20. Euclid’s algorithm: correctness<br>
slide21. Euclid’s algorithm: correctness<br>
slide22. Euclid’s algorithm: correctness g=gcd(a,b) Proved!<br>
slide23. Euclid’s algorithm: speed How many iterations?<br>
slide24. Euclid’s algorithm: speed<br>
slide25. Euclid’s algorithm: speed<br>
slide26. Euclid’s algorithm: speed<br>
slide27. Euclid’s algorithm: speed<br>
slide28. 3. Extended Euclid’s algorithm Using algorithms to do math! 28<br>
slide29. Extended Euclid’s algorithm<br>
slide30. Extended Euclid’s algorithm<br>
slide31. Extended Euclid’s algorithm<br>