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.(adsbygoogle = window.adsbygoogle || []).push({});

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:

233168Code (Python):

max = 1000

result = 0

for i in range(0,max):

if i%3 == 0 or i%5 == 0:

result += i

print result

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

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Project euler 1 understanding the python code

Tags:

Loading...

Similar Threads - Project euler understanding | Date |
---|---|

Python Projects involving data science | Jan 8, 2018 |

Project Euler solution 3 | Aug 30, 2017 |

Computer and electrical engineering projects | Jan 18, 2017 |

Project Euler programming challenges: Am I missing something? | Jan 23, 2014 |

Project Euler - What you've learned | Sep 16, 2009 |

**Physics Forums - The Fusion of Science and Community**