| author | paulson <lp15@cam.ac.uk> | 
| Sat, 17 Oct 2020 11:32:03 +0100 | |
| changeset 72492 | 2dd41a8893aa | 
| parent 45044 | 2fae15f8984d | 
| permissions | -rw-r--r-- | 
| 45044 | 1 | package body Simple_Greatest_Common_Divisor | 
| 2 | is | |
| 3 | ||
| 4 | procedure G_C_D (M, N : in Natural; G : out Natural) | |
| 5 | is | |
| 6 | C, D, R : Natural; | |
| 7 | begin | |
| 8 | C := M; D := N; | |
| 9 | while D /= 0 | |
| 10 | --# assert Gcd (C, D) = Gcd (M, N); | |
| 11 | loop | |
| 12 | R := C mod D; | |
| 13 | C := D; D := R; | |
| 14 | end loop; | |
| 15 | G := C; | |
| 16 | end G_C_D; | |
| 17 | ||
| 18 | end Simple_Greatest_Common_Divisor; |