Last active
August 29, 2015 14:05
-
-
Save akameco/634b3e65664c1f79d970 to your computer and use it in GitHub Desktop.
rubyでfizzbuzz
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
# coding: utf-8 | |
fizz = -> (n) { n % 3 == 0 } | |
buzz = -> (n) { n % 5 == 0 } | |
fizzbuzz = -> (n) { fizz.call(n) and buzz.call(n) } | |
(1..30).each do |v| | |
case v | |
when fizzbuzz | |
puts "fizzbuzz" | |
when fizz | |
puts "fizz" | |
when buzz | |
puts "buzz" | |
else | |
puts v | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment