""" problem 1 from projecteuler.net Find the sum of all the numbers below 1000 which are not multiples of 3 or 5. """ def divisible_by(a, b): """ Return True if a is divisible by b >>> divisible_by(10, 3) False >>> divisible_by(10, 2) True """ return a % b == 0 # this also works #if a % b == 0: # return True #else: # return False def main(): total = 0 for i in range(1, 1000): # 1 to 999 if divisible_by(i, 3) or divisible_by(i,5): total = total + i ## this also works #if divisible_by(i, 3): # total = total + i #elif divisible_by(i, 5): # total = total + i print "The answer is ", total if __name__ == "__main__": import doctest doctest.testmod() main()