jessicakennedy1028

Ruby FizzBuzz Example

Sep 9th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.21 KB | None | 0 0
  1. 1.upto(100) do |i|
  2.   fizz = (i % 3 == 0)
  3.   buzz = (i % 5 == 0)
  4.   puts case
  5.        when fizz && buzz then 'FizzBuzz'
  6.        when fizz then 'Fizz'
  7.        when buzz then 'Buzz'
  8.        else i
  9.        end
  10. end
Advertisement
Add Comment
Please, Sign In to add comment