Euclidean algorithm

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

gcd ( a, b )
{
while ( b ≠ 0 )
{
t = b;
b = a  mod  b;
a = t;
}
return a;
}

Leave a Reply