In this lab, you will determine the least common multiple (LCM) of two numbers in memory named datax and datay. The calculated LCM value should be stored in the area of memory directly following the...


In this lab, you will determine the least common multiple (LCM) of two<br>numbers in memory named datax and datay. The calculated LCM value<br>should be stored in the area of memory directly following the given data. To<br>calculate the LCM, you can first find the greatest common divisor (GCD) of<br>the two numbers and use the formula LCM(xy)*GCD(x,y) = x*y.<br>To find the GCD, you can use Dijkstra's Algorithm to forgo the use of division<br>or modulus functions. Pseudocode (C code) for Dijkstra's Algorithm used to<br>find the GCD is as follows:<br>int GCD(int x, int y) {<br>if(x == y)<br>return x;<br>else<br>if(x > y)<br>return gcd(x-y, y);<br>else<br>return gcd(x, y-x);<br>}<br>Notice that you are passing values in and out of subroutines, which is the<br>focus of lecture this week. You may choose any of the 3 methods (pass by<br>registers, reference, or stack) that you feel is most appropriate.<br>

Extracted text: In this lab, you will determine the least common multiple (LCM) of two numbers in memory named datax and datay. The calculated LCM value should be stored in the area of memory directly following the given data. To calculate the LCM, you can first find the greatest common divisor (GCD) of the two numbers and use the formula LCM(xy)*GCD(x,y) = x*y. To find the GCD, you can use Dijkstra's Algorithm to forgo the use of division or modulus functions. Pseudocode (C code) for Dijkstra's Algorithm used to find the GCD is as follows: int GCD(int x, int y) { if(x == y) return x; else if(x > y) return gcd(x-y, y); else return gcd(x, y-x); } Notice that you are passing values in and out of subroutines, which is the focus of lecture this week. You may choose any of the 3 methods (pass by registers, reference, or stack) that you feel is most appropriate.

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here