

810092048 - shawndumas
http://rosettacode.org/wiki/FizzBuzz#Without_modulus

======
shawndumas
Can someone explain this to me please...

    
    
      messages = [None, "Fizz", "Buzz", "FizzBuzz"]
      acc = 810092048
      for i in xrange(1, 101):
          c = acc & 3
          print messages[c] if c else i
          acc = acc >> 2 | c << 28

~~~
what
Look at the binary representation of acc.

    
    
           11 00 00 01 00 10 01 00 00 01 10 00 01 00 00
    

When you take each group of 2 bits (starting with the least significant group)
and take the bitwise AND with 3, you'll get 0, 1, 2 or 3 (obviously). When you
run those results through the print statement, you'll get the correct pattern
of Fizz Buzzes for the numbers 1-15. This pattern of Fizz Buzzes will repeat.
So, acc >> 2 | c << 28 moves the last 2 bits to the front, making the pattern
of bits repeat. After 15 iterations of the loop, acc will be 810092048 again.

Communication isn't my strong point, so I hope that makes sense.

~~~
shawndumas
if only i could up-vote twice... thanks!

