Last active
January 9, 2017 17:23
-
-
Save gjones/186066df8d25da35642b1a2018fa62cc to your computer and use it in GitHub Desktop.
Attempt at FizzBuzz solution in Ruby
This file contains hidden or 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
# Write a program that prints the numbers from 1 to 100. | |
# For multiples of three print "Fizz" instead of the number | |
# For multiples of five print "Buzz". For numbers which | |
# For multiples of both three and five print "FizzBuzz". | |
1.step(100,1) do |input| | |
if (input % 5) == 0 && (input % 3) == 0 | |
puts 'FizzBuzz' | |
elsif (input % 5) == 0 | |
puts 'Buzz' | |
elsif (input % 3) == 0 | |
puts 'Fizz' | |
else | |
puts input | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment