Skip to content

Instantly share code, notes, and snippets.

@polycarpou
Created September 25, 2013 22:33
Show Gist options
  • Save polycarpou/6707017 to your computer and use it in GitHub Desktop.
Save polycarpou/6707017 to your computer and use it in GitHub Desktop.
fizzbuzz day 3 homework assignment
def fizzbuzz(x)
if x%3 ==0 && x%5 ==0
puts "fizzbuzz"
elsif x%3 ==0
puts "fizz"
elsif x%5 ==0
puts "buzz"
end
end
fizzbuzz(5)
def fizzbuzz_group
fizzbuzz = []
fizz = []
buzz = []
(1..50).each do |x|
if x%3 ==0 && x%5 ==0
fizzbuzz << x
elsif x%3 ==0
fizz << x
elsif x%5 ==0
buzz << x
end
end
return fizzbuzz, fizz, buzz
end
p fizzbuzz_group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment