From: j8takagi Date: Sun, 28 Oct 2012 14:05:21 +0000 (+0900) Subject: Ruby版のロジックを修正 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90af37d67b62fe8f6de059c8ab10ce5c4ae781b9;p=fizzbuzz.git Ruby版のロジックを修正 --- diff --git a/ruby/fizzbuzz.rb b/ruby/fizzbuzz.rb index 60ab1b1..55b7316 100755 --- a/ruby/fizzbuzz.rb +++ b/ruby/fizzbuzz.rb @@ -1,10 +1,17 @@ #!/usr/local/bin/ruby def puts_fizzbuzz(n) - print "Fizz" if fizz = (n % 3 == 0) - print "Buzz" if buzz = (n % 5 == 0) - print n if not fizz and not buzz - print "\n" + fizz = (n % 3 == 0) + buzz = (n % 5 == 0) + if fizz and buzz + puts("FizzBuzz") + elsif fizz + puts("Fizz") + elsif buzz + puts("Buzz") + else + puts(n) + end end min = 1