Last active
August 29, 2015 14:00
-
-
Save jboursiquot/7943660e44b9e292f55f to your computer and use it in GitHub Desktop.
Counting incrementally to 100, print "fizz" any number divisible by 3 and "buzz" any number divisible by 5. Should the number be divisible by 3 and 5, print "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
# Counting incrementally to 100, print "fizz" any number divisible by 3 and "buzz" any number divisible by 5. Should the number be divisible by 3 and 5, print "fizzbuzz". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
100.times do |number|
target = number + 1
if target % 15 == 0
puts "fizzbuzz"
elsif target % 5 == 0
puts "buzz"
elsif target % 5 == 0
puts "fizz"
else
puts target
end