projects
/
fizzbuzz.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
91e79e4
)
Ruby版のロジックを修正
author
j8takagi
<info@j8takagi.net>
Sun, 28 Oct 2012 14:05:21 +0000
(23:05 +0900)
committer
j8takagi
<info@j8takagi.net>
Sun, 28 Oct 2012 14:05:21 +0000
(23:05 +0900)
ruby/fizzbuzz.rb
patch
|
blob
|
history
diff --git
a/ruby/fizzbuzz.rb
b/ruby/fizzbuzz.rb
index
60ab1b1
..
55b7316
100755
(executable)
--- 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