diff options
author | Flavian Kaufmann <flavian@flaviankaufmann.ch> | 2025-05-22 15:16:40 +0200 |
---|---|---|
committer | Flavian Kaufmann <flavian@flaviankaufmann.ch> | 2025-05-22 15:16:40 +0200 |
commit | 987a7c553701251d48b11a2243892ecd74ce6c4d (patch) | |
tree | 92ba268dc32b33724fbb05b6500af7288dac9617 /examples/gcd.imp | |
parent | 056adf22dcbeacbbd64623961f2b8825420f90c5 (diff) | |
download | imp-987a7c553701251d48b11a2243892ecd74ce6c4d.tar.gz imp-987a7c553701251d48b11a2243892ecd74ce6c4d.zip |
[doc] added documentation in ast and hashmap headers
Diffstat (limited to 'examples/gcd.imp')
-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); |