2. 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 remainder operator. Write a test program to test the gcd method.
Sample Output:
Enter first number (-1 to exit): 10
Enter second number: 15
GCD is: 5
Enter first number (-1 to exit): 16
Enter second number: 8
GCD is: 8
Enter first number (-1 to exit): 7
Enter second number: 18
GCD is: 1