An alternative to the Euclidean algorithm uses subtraction rather than division to compute greatest common divisors. (After all, division is repeated subtraction.) It is based on the following lemma.
Lemma 4.10.3
If
Algorithm 4.10.3 Computlng gcd's by Subtraction [Given two positive integers A and B, variables a and b are set equal to A and B. Then a repetitive process begins. If
After the last repetition,
Hence, after the last repetition,
Input: A, B [positive integers]
Algorithm Body:
while (
if
else
end while
if a = 0 then
else
[After execution of the if—then-else statement,
Output: gcd [a positive integer]
a. Prove Lemma 4.10.3.
b. Trace the execution of Algorithm 4.10.3 for
c. Trace the Execution of Algorithm 4.10.3 for
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Discrete Mathematics With Applications
- Elements Of Modern AlgebraAlgebraISBN:9781285463230Author:Gilbert, Linda, JimmiePublisher:Cengage Learning,College AlgebraAlgebraISBN:9781305115545Author:James Stewart, Lothar Redlin, Saleem WatsonPublisher:Cengage Learning