Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shortest Ruby FizzBuzz Implementation
# Shortest FizzBuzz
def fizzbuzz(size)
1.upto size do |num|
yield num % 15 == 0 ? 'FizzBuzz' : num % 5 == 0 ? 'Buzz' : num % 3 == 0 ? 'Fizz' : num.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment