Created
April 17, 2012 19:45
-
-
Save adamjleonard/2408552 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fizzbuzz = (['fizz' unless i % 3] + ['buzz' unless i % 5] or i for i in [1..100]) | |
console.log fizzbuzz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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