Skip to content

Instantly share code, notes, and snippets.

@jboursiquot
Last active August 29, 2015 14:00
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 jboursiquot/7943660e44b9e292f55f to your computer and use it in GitHub Desktop.
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".
# 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".
@BostonREB
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment