1
m = 0
for i in range(1,1000):
    if i % 3 == 0 or i % 5 == 0:
        m += m
print m

This gives 0 as answer. Answer should be 233168.

Could the line ending in my IDE be an issue? I am using pycharm.

EDIT: note to self - take a break. I found the typo as soon as I posted this. I was having some problem with ide and line ending just before this. anyway thanks :) Troll away

Abhishek Dujari
  • 2,343
  • 33
  • 43

1 Answers1

5

Note the line:

m += m

You're adding m to m itself; i.e. you're always adding 0 to 0.

You probably meant:

m += i
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
millimoose
  • 39,073
  • 9
  • 82
  • 134