SHARE
TWEET

Ruby FizzBuzz Example

jessicakennedy1028 Sep 9th, 2018 (edited) 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top