Tag Archives: algorithm

Euclidean algorithm

// Euclidean algorithm – GCD (Greatest Common Divisor)
// Algoritmo de Euclides – MDC (Maior Divisor Comum)

gcd ( a, b )
{
while ( b ≠ 0 )
{
temp = b;
b = a  mod  b;  // remainder of a division
a = temp;
}
return a;
}