Question: Translate into Java the following pseudo-code, expressed in plain English. Goal: Compute the Greater Common Divisor (GCD) of two positive int values given as parameters,

 Translate into Java the following pseudo-code, expressed in plain English. Goal:

Translate into Java the following pseudo-code, expressed in plain English. Goal: Compute the Greater Common Divisor (GCD) of two positive int values given as parameters, named "nl" and "n2". Variables declarations & initialization: No variables needed for this program, we just use the parameters. Steps for the code: While the value stored in variable "nl" is different than the value stored in variable "n2", do the follow: Compare the contents of "ni" and "n2. If the value stored in "n1" is greater than that stored in "n2", then decrement the value stored in "n1" by the value stored in "n2". Otherwise, decrement the value stored in "n2" by the value stored in "n1". After the end of your loop, return the value stored in "n1". gcd(2, 2) - 2 gcd(5,5) - 5 gcd(4, 12) - 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!