Last active
August 29, 2015 14:27
-
-
Save andersr/026dfe24ead36d81cc9b to your computer and use it in GitHub Desktop.
A program that prints out the numbers 1 to 100 (inclusive). If the number is divisible by 3, print Crackle instead of the number. If it's divisible by 5, print Pop. If it's divisible by both 3 and 5, print CracklePop.
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
(1..100).each do |number| | |
if (number % 3 == 0) && (number % 5 == 0) | |
puts "CracklePop" | |
elsif number % 3 == 0 | |
puts "Crackle" | |
elsif number % 5 == 0 | |
puts "Pop" | |
else | |
puts number | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment