Skip to content

Commit 1b407f0

Browse files
Add Fizz Buzz in Smalltalk (#4029)
1 parent 2e53e89 commit 1b407f0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

archive/s/smalltalk/fizz-buzz.st

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"Loop 1 to 100"
2+
1 to: 100 do: [ :i |
3+
4+
"If the number isn't divisible by 3 or 5, show the number"
5+
i \\ 3 = 0 ifFalse: [i \\ 5 = 0 ifFalse: [Transcript show: (i printString); cr]].
6+
7+
"If the number is divisible by 3 AND 5, show 'FizzBuzz'"
8+
i \\ 3 = 0 ifTrue: [i \\ 5 = 0 ifTrue: [Transcript show: 'FizzBuzz' ; cr]].
9+
10+
"If the number is only divisible by 3, show 'Fizz'"
11+
i \\ 3 = 0 ifTrue: [i \\ 5 = 0 ifFalse: [Transcript show: 'Fizz' ; cr]].
12+
13+
"If the number is only divisible by 5, show 'Buzz"
14+
i \\ 5 = 0 ifTrue: [i \\ 3 = 0 ifFalse: [Transcript show: 'Buzz' ; cr]].
15+
].

0 commit comments

Comments
 (0)