Created
June 9, 2013 21:16
-
-
Save stevenabrooks/5745259 to your computer and use it in GitHub Desktop.
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
def fizzbuzz () | |
number = 1 | |
group_fizz = [] | |
group_buzz = [] | |
group_fizzbuzz = [] | |
while number <= 50 | |
case | |
when number % 3 == 0 | |
puts "fizz" | |
group_fizz.push(number) | |
when number % 5 == 0 | |
puts "buzz" | |
group_buzz.push(number) | |
when number % 3 == 0 && number % 5 == 0 | |
puts "fizzbuzz" | |
group_fizzbuzz.push(number) | |
else | |
puts "#{number}" | |
end | |
number += 1 | |
end | |
puts "the fizz group is #{group_fizz}" | |
puts "the buzz group is #{group_buzz}" | |
puts "the fizzbuzz group is #{group_fizzbuzz}" | |
end | |
fizzbuzz() | |
puts "#{group_fizz}" | |
puts "#{group_buzz}" | |
puts "#{group_fizzbuzz}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment