From 90af37d67b62fe8f6de059c8ab10ce5c4ae781b9 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Sun, 28 Oct 2012 23:05:21 +0900 Subject: [PATCH] =?utf8?q?Ruby=E7=89=88=E3=81=AE=E3=83=AD=E3=82=B8?= =?utf8?q?=E3=83=83=E3=82=AF=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ruby/fizzbuzz.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 -- 2.18.0