aboutsummaryrefslogtreecommitdiff
path: root/examples/sum-first-odd-integers.eurm
diff options
context:
space:
mode:
Diffstat (limited to 'examples/sum-first-odd-integers.eurm')
-rw-r--r--examples/sum-first-odd-integers.eurm20
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/sum-first-odd-integers.eurm b/examples/sum-first-odd-integers.eurm
new file mode 100644
index 0000000..f3e6ddb
--- /dev/null
+++ b/examples/sum-first-odd-integers.eurm
@@ -0,0 +1,20 @@
1COMMENT Compute sum 1 + 3 + 5 + ... + n, where n is the greatest
2COMMENT integer less or equal to the initial value of Register 1.
3
4COMMENT Initialization
5ZERO 2
6INC 2
7ZERO 3
8
9COMMENT Main loop
10LABEL loop
11EQ? 2 1 continue
12GEQ? 2 1 done
13LABEL continue
14ADD 3 2
15INC 2
16INC 2
17GOTO loop
18
19LABEL done
20COPY 1 3