annotate lab3/gcd.p @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
rev   line source
0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
1 (* lab3/gcd.p *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
3 var x, y;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 x := 3 * 37; y := 5 * 37;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 while x <> y do
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 if x > y then
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 x := x - y
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10 else
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11 y := y - x
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 end
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 print x; newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 end.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 (*<<
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18 37
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 >>*)