From 1977b7ad1e86d2b922737eb04741607e9c9a991a Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Fri, 24 Feb 2023 23:03:33 +1300 Subject: Better printing functions --- examples/factors-of-n.dsl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'examples/factors-of-n.dsl') 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 -- cgit v1.2.1