jessicakennedy1028 icon

Ruby FizzBuzz Example

jessicakennedy1028 | PRO | 09/09/18 11:06:30 AM UTC | 0 ⭐ | 6998 👁️ | Never ⏰ | []
Ruby |

210 B

|

None

|

0 👍

/

0 👎

1.upto(100) do |i| 
  fizz = (i % 3 == 0)
  buzz = (i % 5 == 0)
  puts case
       when fizz && buzz then 'FizzBuzz'
       when fizz then 'Fizz'
       when buzz then 'Buzz'
       else i
       end
end

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎