Skip to content

Commit 951cbf8

Browse files
authored
Add Fizz Buzz in Forth (#4344)
1 parent d78939c commit 951cbf8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

archive/f/forth/fizz-buzz.fth

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
: divisible
2+
mod 0=
3+
;
4+
5+
: fizz-buzz
6+
dup 15 divisible if
7+
drop
8+
." FizzBuzz"
9+
else
10+
dup 5 divisible if
11+
drop
12+
." Buzz"
13+
else
14+
dup 3 divisible if
15+
drop
16+
." Fizz"
17+
else
18+
.
19+
endif
20+
endif
21+
endif
22+
;
23+
24+
: fizz-buzz-loop
25+
101 1 do i fizz-buzz cr loop
26+
;
27+
28+
fizz-buzz-loop
29+
bye

0 commit comments

Comments
 (0)