The int gcd(int x, int y) recursive function finds the GCD of two integers, x and y, using the following three rules:
- If y=0, the GCD of x and y is x.
- If x mod y is 0, the GCD of x and y is y.
- Otherwise, the GCD of x and y is gcd(y, (x mod y)).
Follow the given steps to find the GCD of two integers recursively:
- You will be prompted to enter two integers. Assign the integers entered to two variables, u and v:
printf("Enter two numbers: ");scanf("%d %d",&x,&y);
- Invoke the gcd function and pass the x and y values to it. The x and y values will be assigned to the a and b parameters, respectively. Assign the GCD value returned by the gcd function to the g variable:
g=gcd(x,y);
- In the gcd function, a % b is executed. The