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
# 標準入力から得られた数字までの FizzBuzz を出力 | |
# 引数に 1 ~ 100 の数値を指定してコマンドラインで以下を実行 | |
$ ruby -e 'raise "illegal arguments. $ {this code} 1 to 100 number argument." unless [*1..100].include?(ARGV[0].to_i); 1.upto(ARGV[0].to_i){|i| out="#{[:Fizz][i%3]}#{[:Buzz][i%5]}"; p out.empty? ? i : out}' | |