Skip to content

Instantly share code, notes, and snippets.

@Chryus
Created November 15, 2013 00:56
Show Gist options
  • Save Chryus/7477332 to your computer and use it in GitHub Desktop.
Save Chryus/7477332 to your computer and use it in GitHub Desktop.
FizzBuzz with Ruby
#prints numbers 1-100
#when the number is divisible by 3, say fizz
#when the number is divisible by 5 say buzz
#when the number is divisible by 3 and 5 say fizzbuzz
i = 1
while i < 101
if i % 3 == 0
puts "fizz"
elsif i % 5 == 0
puts "buzz"
elsif i % 3 == 0 && i % 5 == 0
puts "fizzbuzz"
else
puts i
end
i = i + 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment