#!/usr/bin/python # -*- coding: utf-8 -*- """In http://seldo.com/weblog/2014/08/26/you_suck_at_technical_interviews, the CTO of npm, inc., says: > The famous fizzbuzz test simply asks “are you aware of the modulo operator?” If the answer is “no” then they are probably a pretty weak candidate, but it provides exactly 1 bit of data. Yet people will spend twenty minutes on it in an interview, a huge waste of limited time. So I thought I’d write a Fizzbuzz without using the modulo operator. I’m not sure if it took me an entire two minutes. """ def main(): fizz = 3 buzz = 5 for i in range(1, 101): fizz -= 1 buzz -= 1 if fizz == 0 and buzz == 0: print "FizzBuzz" fizz = 3 buzz = 5 elif fizz == 0: print "Fizz" fizz = 3 elif buzz == 0: print "Buzz" buzz = 5 else: print i if __name__ == '__main__': main()