summaryrefslogtreecommitdiff
path: root/examples/factors-of-n.dsl
diff options
context:
space:
mode:
Diffstat (limited to 'examples/factors-of-n.dsl')
-rw-r--r--examples/factors-of-n.dsl12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/factors-of-n.dsl b/examples/factors-of-n.dsl
index a5ef2fc..9c6608f 100644
--- a/examples/factors-of-n.dsl
+++ b/examples/factors-of-n.dsl
@@ -5,15 +5,17 @@ PROC factors
''' find the smallest number that divides n '''
2 WHILE OVER OVER SWAP % 0 != DO 1 + END
''' print it and find the next factor '''
- DUP .
+ DUP PUT " " PUT
OVER OVER SWAP / factors
+ ELSE
+ "" PUTLN
END
END
PROC MAIN
- "Prime factors of 12:" . 12 factors
- "Prime factors of 5:" . 5 factors
- "Prime factors of 60:" . 60 factors
- "Prime factors of 97:" . 97 factors
+ "Prime factors of 12:" PUTLN 12 factors
+ "Prime factors of 5:" PUTLN 5 factors
+ "Prime factors of 60:" PUTLN 60 factors
+ "Prime factors of 97:" PUTLN 97 factors
END