euclid's algorithm example
Example 1: euclid algorithm
int Euclid(int a, int b)
{
int r;
while(b != 0)
{
r = a % b;
a = b;
b = r;
}
return a;
}
Example 2: euclid algorithm
function mcd($a,$b) {
while($b) list($a,$b)=array($b,$a%$b);
return $a;
}
Example 3: euclid algorithm
def MCD(a,b):
while b != 0:
a, b = b, a % b
return a