Skip to content

Instantly share code, notes, and snippets.

@akameco
Last active August 29, 2015 14:05
Show Gist options
  • Save akameco/634b3e65664c1f79d970 to your computer and use it in GitHub Desktop.
Save akameco/634b3e65664c1f79d970 to your computer and use it in GitHub Desktop.
rubyでfizzbuzz
# 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