Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FizzBuzz with ruby
(1..ARGV[0].to_i).each do |i|
s = (i % 3).zero? ? 'Fizz' : ''
b = (i % 5).zero? ? 'Buzz' : ''
s << b
puts s.empty? ? i.to_s : s
end
@s-tammy-kato

This comment has been minimized.

Copy link
Owner Author

commented Apr 16, 2019

もっと短く書けそうな気がしなくもない

@s-tammy-kato

This comment has been minimized.

Copy link
Owner Author

commented Apr 25, 2019

zero? より === 0 のが速いらしい、かなしい

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.