The C expression m % n yields the remainders of m divided by n. Define the greatest common divisor (GCD) of two integers x and y by:
| gcd(x, y) = y | if (y <= x && x % y == 0) |
| gcd(x, y) = gcd(y, x) | if (x < y) |
| gcd(x, y) = gcd(y, x % y) | otherwise |
Rewrite the algorithm as an iterative method in C/C++/Java (your choice). Write a main program (both method and main program properly commented) that will run it with the data sets below:
| x | y |
|---|---|
| 32 | 8 |
| 24 | 15 |
| 64 | 48 |