Skip to content

Instantly share code, notes, and snippets.

@Wilfred
Created June 7, 2014 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wilfred/618f0ce8e047fcbdf24e to your computer and use it in GitHub Desktop.
Save Wilfred/618f0ce8e047fcbdf24e to your computer and use it in GitHub Desktop.
Fizzbuzz.st
'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