Here is how this algorithm works step-by-step: Step 1: a = 345 and b = 89 Step 2: 345 ÷ 89 = 3 with remainder 68, so a = b * q + r = 3 * 89 + 78 = 345 Step 3: Since r != 0, go to step 4 Step 4: b = 89, r = 78, go back to step 2 Step 2: 89 ÷ 78 = 1 with remainder 11, so a = b * q + r = 1 * 78 + 11 = 89 Step 3: Since r != 0, go to step 4 Step 4: b= 78, r = 11, go back to step 2 Step 2: 78 ÷ 11 = 7 with remainder 1, so a = b * q + r = 7 * 11 +1 = 78 Step 3: Since r != 0, go to step 4 Step 4: b= 11, r = 1, go back to step 2 Step 2: 11 ÷ 1 = 11 with remainder 0, so a = b * q + r = 11 * 1 + 0 = 11 Step 3: Since r = 0, the algorithm stops and GCD(345, 89) = b = 1.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter2: Problem Solving Using C++using
Section2.4: Arithmetic Operations
Problem 6E
icon
Related questions
Question

Here is how this algorithm works step-by-step:
Step 1: a = 345 and b = 89
Step 2: 345 ÷ 89 = 3 with remainder 68, so a = b * q + r = 3 * 89 + 78 = 345
Step 3: Since r != 0, go to step 4
Step 4: b = 89, r = 78, go back to step 2
Step 2: 89 ÷ 78 = 1 with remainder 11, so a = b * q + r = 1 * 78 + 11 = 89
Step 3: Since r != 0, go to step 4
Step 4: b= 78, r = 11, go back to step 2
Step 2: 78 ÷ 11 = 7 with remainder 1, so a = b * q + r = 7 * 11 +1 = 78
Step 3: Since r != 0, go to step 4
Step 4: b= 11, r = 1, go back to step 2
Step 2: 11 ÷ 1 = 11 with remainder 0, so a = b * q + r = 11 * 1 + 0 = 11
Step 3: Since r = 0, the algorithm stops and GCD(345, 89) = b = 1.

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

You are required to use a menu option to allow the user to enter two numbers and find the results as
many times as they want and allow the user to quit when they no longer want to use the system. Use
variables, decision statements, and loops to solve the problem. 

 

It should be pseudocode not python

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr