Invitation to Computer Science 8th Edition

Published by Cengage Learning
ISBN 10: 1337561916
ISBN 13: 978-1-33756-191-4

Chapter 1 - Exercises - Page 39: 10a

Answer

a) After performing the algorithm the answer is $J=4$

Work Step by Step

a) Perform the steps and keep track of the values $I, J$ and $R$ $\bullet$ Let $I=32$ and $J=20 \quad \quad I=32 ; J=20 ; R=0$ $\bullet 32$ divided by 20 leaves us with $R=12$ as a remainder $\quad \quad I=32 ; J=20 ; R=12$ $\bullet 2$ is not equal to 0 so $I=20$ and $J=12 \quad \quad I=20 ; J=12 ; R=12$ $\bullet 20$ divided by 12 gives $R=8 \quad \quad I=20 ; J=12 ; R=8$ $\bullet 8 \neq 0$ so $I=12$ and $J=8\quad \quad I=12 ; J=8 ; R=8$ $\bullet 12 / 8$ gives 4 as remainder $\quad \quad I=12 ; J=8 ; R=4$ $\bullet 4 \neq 0$ so $I=8$ and $J=4 \quad \quad {I=8 ; J=4 ; R=4}$ $\bullet 8 / 4$ gives 0 as a remainder $\quad \quad I=8 ; J=4 ; R=0$ $\bullet R=0$ so the answer is $\quad \quad \quad J=4$
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.