Created
August 8, 2013 19:57
-
-
Save AJ-Acevedo/6188138 to your computer and use it in GitHub Desktop.
Fizz Buzz - Written in Ruby
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
#!/usr/bin/env ruby | |
# Fizz Buzz | |
# Copyright (c) 2013 AJ Acevedo | http://ajacevedo.com | |
# This content is released under the MIT License. | |
# http://www.opensource.org/licenses/mit-license.php | |
# Version: 0.1 | |
# The heavy lifting of Fizz Buzz | |
def fizz_buzz?(count) | |
case | |
when count % 15 == 0 | |
"Fizz Buzz" | |
when count % 3 == 0 | |
"Fizz" | |
when count % 5 == 0 | |
"Buzz" | |
else count | |
end | |
end | |
# Fizz Buzz Output | |
def fizz_buzz_output | |
1.upto(100).each do |count| | |
puts fizz_buzz?(count) | |
end | |
end | |
puts `clear` | |
puts 'Fizz Buzz solution by AJ Acevedo' | |
puts '' | |
puts fizz_buzz_output | |
puts '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment