Greatest Common Denominator
Non-Recursive implementation of the Euclidean Algorithm to find the greatest common denominator (GCD) between two numbers.
public int GCD(int a, int b)
{
while (a != 0 && b != 0)
{
if (a > b)
a %= b;
else
b %= a;
}
if (a == 0)
return b;
else
return a;
}
Reference: http://www.vcskicks.com/euclidean-gcd.php