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, 22.06.2019 07:30
In the film "epic 2015," epic is the name for:
Answers: 3
question
Computers and Technology, 23.06.2019 17:30
Scientists have changed the model of the atom as they have gathered new evidence. one of the atomic models is shown below. what experimental evidence led to the development of this atomic model from the one before it? a few of the positive particles aimed at a gold foil seemed to bounce back. the colors of light emitted from heated atoms had very specific energies. experiments with water vapor showed that elements combine in specific proportions. cathode rays were bent in the same way whenever a magnet was brought near them.
Answers: 2
question
Computers and Technology, 23.06.2019 18:00
Apunishment or the threat of punishment used to enforce conformity. select the best answer from the choices provided t f
Answers: 1
question
Computers and Technology, 24.06.2019 01:00
Me if you do then you get 10 points and brainliest
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
Computers and Technology, 30.03.2021 20:40
question
Mathematics, 30.03.2021 20:40
Questions on the website: 13722367