euclidean algorithm code 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: gcd algorithm
function gcd(a, b)
if b = 0
return a
else
return gcd(b, a mod b)
Example 3: euclid algorithm
function mcd($a,$b) {
while($b) list($a,$b)=array($b,$a%$b);
return $a;
}
Example 4: euclidean distance
The distance between two points based on the pythagoream theorem