- #1
Niaboc67
- 249
- 3
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.
This is the code for python I found (didn't create) which I believe is correct:
233168
Trying to see if I have this right. The max is setting the variable equal to 1000. and "for" is creating the for loop to find an integer in the range between 0 and max which is set to be 1000. What is going on with the if i%3 == 0 or i%5 == 0: I don't understand that line why the percent sign and why i? Is that saying the all integers which are either multiples or 3 or 5? why the == 0? and why the result += i?
Thank you
stand what the ddd
Find the sum of all the multiples of 3 or 5 below 1000.
This is the code for python I found (didn't create) which I believe is correct:
Python:
max = 1000
result = 0
for i in range(0,max):
if i%3 == 0 or i%5 == 0:
result += i
print result
233168
Trying to see if I have this right. The max is setting the variable equal to 1000. and "for" is creating the for loop to find an integer in the range between 0 and max which is set to be 1000. What is going on with the if i%3 == 0 or i%5 == 0: I don't understand that line why the percent sign and why i? Is that saying the all integers which are either multiples or 3 or 5? why the == 0? and why the result += i?
Thank you
stand what the ddd
Last edited by a moderator: