Multiples of 3 and 5
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.
First I have written my program for number up to 10. This ensures me that if anything goes wrong at this stage I can sort it out.
Also I have commented each and every part of the program which makes it easy even for beginners to understand the program.
I think at this stage you might want to know about the string formatting using
%
and .format
for which you can see Basic Formatting on PyFormat
If you want you can download the file from Github
Output
If you have any doubt or didn't understand any part of the code then comment in the comment box below and I will be glad to help you. You can also contact me if you want.
See Solution to Project Euler Problem 2 with python