diff --git a/fizzbuzz.rb b/fizzbuzz.rb index 4b907f0..aa1f5a8 100644 --- a/fizzbuzz.rb +++ b/fizzbuzz.rb @@ -1,7 +1,16 @@ class Integer - def fizzbuzz - # - # YOUR CODE GOES HERE - # - end +def fizzbuzz + (1..20).each do |x| + m3 = x.modulo(3) == 0 + m5 = x.modulo(5) == 0 + + puts case + when (m3 and m5) then 'FizzBuzz' + when m3 then 'Fizz' + when m5 then 'Buzz' + else x + end + end end +end +