subject
Computers and Technology, 04.04.2020 02:09 chops85

Recall that the greatest common divisor of two integers a and b, GCD(a, b), not both of which are zero, is the largest positive integer that divides both a and b. The Euclidean algorithm for finding this greatest common divisor of a and b is as follows:
- Divide a by b to obtain the integer quotient q and remainder r so that a = bq + r. Note: if b = 0, then GCD(a, b) = a.
- Now, GCD(a, b) = GCD(b, r) so replace a with b and b with r, and repeat this procedure
Since the remainders are decreasing, eventually a remainder of 0 will result. The last nonzero remainder is GCD(a, b). For example,
1260 = 198 x 6 + 72 GCD(1260,198) = GCD(198,72)
199 = 72 x 2 + 54 GCD(1260,198) = GCD(72,52)
72 = 54 x 1 + 18 GCD(1260,198) = GCD(54,18)
54 = 18 x 3 + 0 GCD(1260,198) = 18

(a) Write a recursive implementation of the Euclidean GCD function:
int gcd(int a, int b);
[Hint: Note that when the remainder is zero, the divisor will be the GCD]
(b) Write a short program to test your GCD function with the following values:

1280,198
197,13
120,60

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:30
Which number on the image above correctly indicates the name of a folder in this url? a.1b.2c.3d.4
Answers: 2
question
Computers and Technology, 22.06.2019 11:10
Look at the far left lane in the picture. explain what the red car is doing and what it needs to do to travel safely.
Answers: 2
question
Computers and Technology, 22.06.2019 18:30
Kto rozmawia z clamentain przez krótkofalówke w the walking dead która śledzi lee w 4 epizodzie
Answers: 1
question
Computers and Technology, 23.06.2019 01:30
Negative methods of behavior correction include all but this: sarcasm verbal abuse setting an example for proper behavior humiliation
Answers: 1
You know the right answer?
Recall that the greatest common divisor of two integers a and b, GCD(a, b), not both of which are ze...
Questions
question
Mathematics, 14.01.2021 19:10
question
Chemistry, 14.01.2021 19:10
question
Mathematics, 14.01.2021 19:10
question
Arts, 14.01.2021 19:10
Questions on the website: 13722367