Find gcd(u, v)
= greatest common divisor of u,v
gcd(24, 60) = 12
(1)Brute - force
t := min(u, v);
while (u mod t <> 0) or (v
mod t <> 0) do t :=
t - 1;
gcd := t;
(2)Euclid's algorithm (輾轉相除法)
.mathematics
:
(u, v) = (v, u-v) = (v, u-2v)
= ......... = (v, u mod v)