We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2e53e89 commit 1b407f0Copy full SHA for 1b407f0
archive/s/smalltalk/fizz-buzz.st
@@ -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