File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
contents/euclidean_algorithm/code/piet Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,36 @@ function gcd(a, b)
7
7
return a;
8
8
9
9
in(number) A
10
+ // absolute of A
11
+ duplicate AA
12
+ push 1 1AA
13
+ duplicate 11AA
14
+ subtract 0AA
15
+ greater 0/1A // 1 if A > 0, 0 if A <= 0
16
+ not 1/0A // 0 if A > 0, 1 if A <= 0
17
+ push 1 1 1/0 A
18
+ push 3 31 1/0 A
19
+ subtract -2 1/0 A
20
+ multiply -2/0 A
21
+ push 1 1 -2/0 A
22
+ add -1/1 A
23
+ multiply A
24
+
10
25
in(number) BA
26
+ // absolute of B
27
+ duplicate BBA
28
+ push 1 1BBA
29
+ duplicate 11BBA
30
+ subtract 0BBA
31
+ greater 0/1BA // 1 if B > 0, 0 if B <= 0
32
+ not 1/0BA // 0 if B > 0, 1 if B <= 0
33
+ push 1 1 1/0 BA
34
+ push 3 31 1/0 BA
35
+ subtract -2 1/0 BA
36
+ multiply -2/0 BA
37
+ push 1 1 -2/0 BA
38
+ add -1/1 BA
39
+ multiply BA
11
40
12
41
// Start of loop
13
42
duplicate BBA
You can’t perform that action at this time.
0 commit comments