Skip to content

Instantly share code, notes, and snippets.

@liquidz
Forked from anonymous/fizzbuzz.pl
Created October 11, 2011 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liquidz/1278058 to your computer and use it in GitHub Desktop.
Save liquidz/1278058 to your computer and use it in GitHub Desktop.
def fizzbuzz(n)
(1..n).map do |x|
res = ""
res += "Fizz" if x % 3 == 0
res += "Buzz" if x % 5 == 0
(res == "") ? x : res
end
end
puts fizzbuzz(15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment