Last active
May 23, 2016 21:49
-
-
Save rosslebeau/d4de0c7044ee5f93581a to your computer and use it in GitHub Desktop.
FizzBuzz in Ruby without conditionals using logarithms - one liner
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
def fizzbuzz limit, start | |
loop do | |
puts "#{'fizz' * (~(((start % 3) >> (Math.log2((start % 3) + 1).ceil - 1)) * 2))[1]}#{'buzz' * (~(((start % 5) >> (Math.log2((start % 5) + 1).ceil - 1)) * 2))[1]}#{start.to_s * ((start % 3) >> (Math.log2((start % 3) + 1).ceil - 1)) * ((start % 5) >> (Math.log2((((start += ((limit + 1) - start)/((limit + 1) - start)) - 1) % 5) + 1).ceil - 1))}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment