Chapter 1: Problem 10
The following is Euclid's 2,300-year-old algorithm for finding the greatest common divisor of two positive integers \(/\) and \(J\). Step Operation 1 Get two positive integers as input; call the larger value / and the smaller value J 2 Divide \(I\) by \(J\), and call the remainder \(R\) 3 If \(R\) is not 0 , then reset \(/\) to the value of \(J\), reset \(J\) to the value of \(R\), and go back to Step 2 4 Print out the answer, which is the value of \(J\) 5 Stop a. Go through this algorithm using the input values 20 and 32 . After each step of the algorithm is completed, give the values of \(I\), \(J\), and \(R\). Determine the final output of the algorithm. b. Does the algorithm work correctly when the two inputs are 0 and 32 ? Describe exactly what happens, and modify the algorithm so that it gives an appropriate error message.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.