Skip to content

Instantly share code, notes, and snippets.

@joelturnbull
Created June 12, 2011 16:42
Show Gist options
  • Save joelturnbull/1021742 to your computer and use it in GitHub Desktop.
Save joelturnbull/1021742 to your computer and use it in GitHub Desktop.
FizzBuzz
^ (integer \\ 15 = 0) ifTrue: [ 'FizzBuzz' ] ifFalse: [
(integer \\ 3 = 0) ifTrue: [ 'Fizz' ] ifFalse: [
(integer \\ 5 = 0) ifTrue: [ 'Buzz' ] ifFalse: [ integer ]
@SeanTAllen
Copy link

OR...

fb := Dictionary with: #(true true) ->'FizzBuzz' 
                            with: #(true false)->'Fizz' 
                            with: #(false true)->'Buzz'.

1 to: 100 do: 
    [ :i | Transcript show: 
               (fb at: {i isDivisibleBy: 3. i isDivisibleBy: 5} 
                     ifAbsent: [ i ]); cr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment