Alternate Recursive Method
The above snippet is equivalent to this, which may better meet your preferenceCan also be written as:
static int GetGCD(int x, int y)
{
// If y is equal to 0, return x.
if (y == 0)
{
return x;
}
// If y is not equal to 0, recursive call with x as y and y as the remainder.
else
{
return GetGCD(y, x % y);
}
}
Depending on your preference.