Last active
June 10, 2016 13:59
-
-
Save redpist/4b916cd55ced84da237e9ebf05ae320c to your computer and use it in GitHub Desktop.
Factorized FizzBuzz based on prime Factorization
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
(1..100).each do |n| | |
magic = n % 3 * 7 + n % 5 * 11 | |
print 'Fizz' if [0, 11, 22, 33, 44].include? magic | |
print 'Buzz' if [0, 7, 14].include? magic | |
print n unless [0, 7, 11, 14, 22, 33, 44].include? magic | |
print "\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment