Skip to content

Instantly share code, notes, and snippets.

@AJ-Acevedo
Created August 8, 2013 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AJ-Acevedo/6188138 to your computer and use it in GitHub Desktop.
Save AJ-Acevedo/6188138 to your computer and use it in GitHub Desktop.
Fizz Buzz - Written in Ruby
#!/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