ahmed sami

ahmed sami

  • NA
  • 64
  • 197.4k

The greatest common divisor of integers x and y

Dec 10 2012 5:26 PM
The greatest common divisor of integers x and y is the largest integer that evenly divides 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 modulus operator.

Answers (2)