Skip to content

Instantly share code, notes, and snippets.

@jhollinger
Created June 3, 2016 03:17
Show Gist options
  • Save jhollinger/1dc41563075129eb076bb9ce1426e95a to your computer and use it in GitHub Desktop.
Save jhollinger/1dc41563075129eb076bb9ce1426e95a to your computer and use it in GitHub Desktop.
def fizzbuzz(input)
input.map do |n|
fizz = n % 3 == 0 ? 'Fizz' : nil
buzz = n % 5 == 0 ? 'Buzz' : nil
if fizz or buzz
"#{fizz}#{buzz}"
else
n.to_s
end
end
end
puts fizzbuzz(1..100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment