Skip to content

Instantly share code, notes, and snippets.

@stevenabrooks
Created June 9, 2013 21:16
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 stevenabrooks/5745259 to your computer and use it in GitHub Desktop.
Save stevenabrooks/5745259 to your computer and use it in GitHub Desktop.
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