The greatest common divisor of integers x and y is the largest integer that evenly divides into

Question:

The greatest common divisor of integers x and y is the largest integer that evenly divides into both x and y. Write a recursive method gcd that returns the greatest common divisor of x and y. The gcd of x and y is defined recursively as follows: If y is equal to 0, then gcd(x, y) is x; otherwise, gcd(x, y) is gcd(y, x % y), where % is the remainder operator. Use this method to replace the one you wrote in the application of Exercise 5.27.

Data From Exercise 5.27:

The greatest common divisor (GCD) of two integers is the largestinteger that evenly divides each of the two numbers. Write a method gcd that returns the greatestcommon divisor of two integers.

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

Step by Step Answer:

Related Book For  book-img-for-question

Java How To Program Late Objects Version

ISBN: 9780136123712

8th Edition

Authors: Paul Deitel, Deitel & Associates

Question Posted: