Last active
April 25, 2019 07:59
-
-
Save s-tammy-kato/c5fe429e2e0aea148ab48891ce526f59 to your computer and use it in GitHub Desktop.
FizzBuzz with ruby
This file contains 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
(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 |
zero? より === 0 のが速いらしい、かなしい
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
もっと短く書けそうな気がしなくもない