Ruby solution


  • 0
    K
    def fizz_buzz(n)
        (1..n).map  {|v| ((v%5).zero? ? (v%3).zero? ? 'FizzBuzz' : 'Buzz' : (v%3).zero? ? 'Fizz' : v.to_s ) }
    end
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.