Skip to content

Instantly share code, notes, and snippets.

@redpist
Last active June 10, 2016 13:59
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 redpist/4b916cd55ced84da237e9ebf05ae320c to your computer and use it in GitHub Desktop.
Save redpist/4b916cd55ced84da237e9ebf05ae320c to your computer and use it in GitHub Desktop.
Factorized FizzBuzz based on prime Factorization
(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