diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gcd.imp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/gcd.imp b/examples/gcd.imp new file mode 100644 index 0000000..5ab0bbf --- /dev/null +++ b/examples/gcd.imp @@ -0,0 +1,16 @@ +/* computes greatest common divisor (gcd) of a and b */ +procedure gcd(a, b; r) begin + if b = 0 then + r := a; + else + q := a; + while q >= b do + q := q - b; + end; + gcd(b, q; r); + end; +end; + +x := 48; +y := 18; +gcd(x, y; result); |