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, 23.06.2019 12:00
What does the level 1 topic in a word outline become in powerpoint? a. first-level bullet item b. slide title c. third-level bullet item d. second-level bullet item
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 2
question
Computers and Technology, 23.06.2019 21:40
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings. for each match, add one point to user_score. upon a mismatch, end the game. sample output with inputs: 'rrgbryybgy' 'rrgbbrybgy'
Answers: 3
question
Computers and Technology, 23.06.2019 23:00
Lucas put a lot of thought into the design for his company's new white paper. he made sure to include repeating design elements such as color schemes and decorative images. his goal was to a.add symmetry b.create a unified publication c.provide consistency d.save money
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
Social Studies, 12.03.2020 22:01
question
Mathematics, 12.03.2020 22:02