aboutsummaryrefslogtreecommitdiff
path: root/examples/factorial.eurm
blob: b2b2566844c81003aa17b615b231ff8b42e4f873 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
COMMENT Compute R1! and place the result in R1

ZERO? 1 R1=0
GOTO R1>0

COMMENT R1 holds 0
LABEL R1=0
INC 1
GOTO done

COMMENT R1 holds a positive integer
LABEL R1>0
COPY 2 1
ZERO 1
INC 1
ZERO 3
INC 3

COMMENT main loop
LABEL loop
MULT 1 3
EQ? 2 3 done
INC 3
GOTO loop

LABEL done
QUIT