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
Get step-by-step solutions from verified subject matter experts
