previous up next
Go backward to Specification
Go up to Top
Go forward to Verification
RISC-Linz logo

Euclid's Algorithm

New knowledge:

(0) forall m in N, n <= m: gcd(m, n) = gcd(m-n, n).

Idea for recursive function definition (termination term m+n):

Euclid(m, n) :=
   if m = 0 then n
   else if n = 0 then m
   else if n <= m then Euclid(m-n, n)
   else Euclid(m, n-m).

Author: Wolfgang Schreiner
Last Modification: November 24, 1999

previous up next