I am a bit confused because i believe I am answering this correctly. This is the question:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
My code is as follows
I just put in some print checks to make sure I am not going crazy, this in my understanding accomplishes the question outputting the sum of all multiples of 3 and 5 below 1000 as "266333"
Could someone just tell me if I am making a very stupid mistake in understanding this?
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
My code is as follows
Code:
def mult(X): List = [] k =1 while X*k <1000: List.append(X*k) k+=1 print List print sum(List[:]) mult(3) mult(5) print 99500+166833
Could someone just tell me if I am making a very stupid mistake in understanding this?
Comment