Skip to content

Instantly share code, notes, and snippets.

@chrisseaton
Last active October 24, 2018 05:25
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 chrisseaton/c09250349aa3f77c4d0f5ad81b2aa450 to your computer and use it in GitHub Desktop.
Save chrisseaton/c09250349aa3f77c4d0f5ad81b2aa450 to your computer and use it in GitHub Desktop.
def fizzbuzz(n)
if n % 3 == 0 && n % 5 == 0
'FizzBuzz'
elsif n % 3 == 0
'Fizz'
elsif n % 5 == 0
'Buzz'
else
n
end
end
(1..20).each do |n|
puts fizzbuzz(n)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment