Write a method called gcd that accepts two integers as parameters and returns the greatest common divisor

Question:

Write a method called gcd that accepts two integers as parameters and returns the greatest common divisor (GCD) of the two numbers. The GCD of two integers a and b is the largest integer that is a factor of both a and b.

One efficient way to compute the GCD of two numbers is to use Euclid’s algorithm, which states the following:

GCD(a, b) = GCD(b, a % b)
GCD(a, 0) = Absolute value of a

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: