Created
June 7, 2014 18:03
-
-
Save Wilfred/618f0ce8e047fcbdf24e to your computer and use it in GitHub Desktop.
Fizzbuzz.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'From Pharo3.0 of 18 March 2013 [Latest update: #30848] on 7 June 2014 at 6:57:07.57647 pm'! | |
Object subclass: #Fizzbuzz | |
instanceVariableNames: '' | |
classVariableNames: '' | |
poolDictionaries: '' | |
category: 'Fizzbuzz'! | |
!Fizzbuzz commentStamp: '<historical>' prior: 0! | |
! | |
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! | |
Fizzbuzz class | |
instanceVariableNames: ''! | |
!Fizzbuzz class commentStamp: '<historical>' prior: 0! | |
! | |
!Fizzbuzz class methodsFor: 'as yet unclassified' stamp: 'WilfredHughes 6/7/2014 18:55'! | |
upTo: value | |
"Write a fizzbuzz sequence to Transcript, up to the value given (inclusive)." | |
| | | |
1 to: value do: [ :x | | |
(x % 15 == 0) | |
ifTrue: [Transcript show: 'FizzBuzz'; cr. ] | |
ifFalse: [(x % 5 == 0) | |
ifTrue: [Transcript show: 'Buzz'; cr. ] | |
ifFalse: [(x % 3 == 0) | |
ifTrue: [ Transcript show: 'Fizz'; cr. ] | |
ifFalse: [ Transcript show: x; cr. ] | |
] | |
] | |
].! ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment