Skip to content

Instantly share code, notes, and snippets.

@adamjleonard
Created April 17, 2012 19:45
Show Gist options
  • Save adamjleonard/2408552 to your computer and use it in GitHub Desktop.
Save adamjleonard/2408552 to your computer and use it in GitHub Desktop.
fizzbuzz = (['fizz' unless i % 3] + ['buzz' unless i % 5] or i for i in [1..100])
console.log fizzbuzz
def multiple_of(current_number, multiple_of)
true if current_number % multiple_of == 0
end
(1..100).each do |num|
if multiple_of(num, 3) || multiple_of(num, 5)
print 'Fizz' if multiple_of(num, 3)
print 'Buzz' if multiple_of(num, 5)
else
print "#{num}"
end
puts ""
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment