Book contents
- Frontmatter
- Contents
- Preface
- Preliminaries
- 1 Basic properties of the integers
- 2 Congruences
- 3 Computing with large integers
- 4 Euclid's algorithm
- 5 The distribution of primes
- 6 Finite and discrete probability distributions
- 7 Probabilistic algorithms
- 8 Abelian groups
- 9 Rings
- 10 Probabilistic primality testing
- 11 Finding generators and discrete logarithms in
- 12 Quadratic residues and quadratic reciprocity
- 13 Computational problems related to quadratic residues
- 14 Modules and vector spaces
- 15 Matrices
- 16 Subexponential-time discrete logarithms and factoring
- 17 More rings
- 18 Polynomial arithmetic and applications
- 19 Linearly generated sequences and applications
- 20 Finite fields
- 21 Algorithms for finite fields
- 22 Deterministic primality testing
- Appendix: Some useful facts
- Bibliography
- Index of notation
- Index
4 - Euclid's algorithm
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Preface
- Preliminaries
- 1 Basic properties of the integers
- 2 Congruences
- 3 Computing with large integers
- 4 Euclid's algorithm
- 5 The distribution of primes
- 6 Finite and discrete probability distributions
- 7 Probabilistic algorithms
- 8 Abelian groups
- 9 Rings
- 10 Probabilistic primality testing
- 11 Finding generators and discrete logarithms in
- 12 Quadratic residues and quadratic reciprocity
- 13 Computational problems related to quadratic residues
- 14 Modules and vector spaces
- 15 Matrices
- 16 Subexponential-time discrete logarithms and factoring
- 17 More rings
- 18 Polynomial arithmetic and applications
- 19 Linearly generated sequences and applications
- 20 Finite fields
- 21 Algorithms for finite fields
- 22 Deterministic primality testing
- Appendix: Some useful facts
- Bibliography
- Index of notation
- Index
Summary
In this chapter, we discuss Euclid's algorithm for computing greatest common divisors. It turns out that Euclid's algorithm has a number of very nice properties, and has applications far beyond that purpose.
The basic Euclidean algorithm
We consider the following problem: given two non-negative integers a and b, compute their greatest common divisor, gcd(a, b). We can do this using the well-known Euclidean algorithm, also called Euclid's algorithm.
The basic idea of Euclid's algorithm is the following. Without loss of generality, we may assume that a ≥ b ≥ 0. If b = 0, then there is nothing to do, since in this case, gcd(a, 0) = a. Otherwise, if b > 0, we can compute the integer quotient q ≔ └a/b┘ and remainder r ≔ a mod b, where 0 ≤ r < b. From the equation
it is easy to see that if an integer d divides both b and r, then it also divides a; likewise, if an integer d divides a and b, then it also divides r. From this observation, it follows that gcd(a, b) = gcd(b, r), and so by performing a division, we reduce the problem of computing gcd(a, b) to the “smaller” problem of computing gcd(b, r).
- Type
- Chapter
- Information
- Publisher: Cambridge University PressPrint publication year: 2005