Go backward to Example: Greatest Common Divisor Go up to Top Go forward to Euclid's Algorithm |
We can show that
forall z in N: exists w: w | 0 /\ w > zi.e., gcd(0, 0) is undefined, but that, if x != 0 \/ y != 0,
exists z in N: z | x /\ z | y /\ (forall w: (w | x /\ w | y) => w <= z).i.e., gcd(x, y) is well defined.
Thus our problem is to find some f that implements the specification
forall m in N, n in N: (m != 0 \/ n != 0) => f(m, n) = gcd(m, n).in a more efficient way than gcd does.