|
|
@@ -1,9 +1,18 @@
|
|
1
|
1
|
(include str maths)
|
|
|
2
|
+
|
|
|
3
|
+;
|
|
|
4
|
+; def: fizzbuzz(1)
|
|
|
5
|
+;
|
|
|
6
|
+; Takes an argument and prints the numbers up to and including the argument
|
|
|
7
|
+; replacing numbers that are divisible by 3, with Fizz, numbers
|
|
|
8
|
+; divisible by 5 with Buzz, and numbers that are divisible by both,
|
|
|
9
|
+; with FizzBuzz
|
|
|
10
|
+;
|
|
2
|
11
|
(def fizzbuzz
|
|
3
|
12
|
(assign i 1)
|
|
4
|
13
|
(repeat $1
|
|
5
|
14
|
(assign result "")
|
|
6
|
|
- (if (eq (maths::modulo i 3) 0) (assign result (str::concat result "Fizz")))
|
|
|
15
|
+ (if (eq (maths::modulo i 3) 0) (assign result "Fizz"))
|
|
7
|
16
|
(if (eq (maths::modulo i 5) 0) (assign result (str::concat result "Buzz")))
|
|
8
|
17
|
(if (eq result "") (assign result i))
|
|
9
|
18
|
(log result)
|