Created
September 25, 2013 22:33
-
-
Save polycarpou/6707017 to your computer and use it in GitHub Desktop.
fizzbuzz day 3 homework assignment
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(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