Question: JAVA: Implement a method public static int gcd(int a, int b) that returns the gcd (greatest common divisor) of two ints a and b where

JAVA:

Implement a method public static int gcd(int a, int b) that returns the gcd (greatest common divisor) of two ints a and b where it's assumed that a > 0 and b >= 0.

To compute the gcd use the following algorithm: if b is 0 then just return a. Otherwise return the gcd of b and a % b.

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!