Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago

Question

What is loss of bone density and strength as ?

Answered: 1 week ago