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. File: pep1.py ------------- #http://radiusofcircle.blogspot.com #Time module for counting time import time #Time at the start of the program start_time = time.time() #For loop for sum less than 10 #To check if we are correct #sum1 variable to store the value of sum less than 10 sum1 = 0 #A for loop to iterate through numbers 1 - 10 for i in range(1,10): if i%3 == 0 or i%5 == 0: sum1 = sum1+i #Printing the result with .format() print 'Sum of Natural Numbers less than 10' print 'That are divisible by 3 or 5 is {}\n'.format(sum1) #For loop for sum less than 1000 #sum2 variable to store the value of sum less than 1000 sum2 = 0 #A for loop to iterate through numbers 1 - 1000 for i in range(1,1000): if i%3 == 0 or i%5 == 0: sum2 = sum2+i #Print...
With Radius of Circle, people can learn to program and have hands-on tutorials with python and Matlab. ProjectEuler problems solutions are also available to have a better solution and improve the knowledge of people. A lot of algorithms which form the basic programming are also available. I hope the internet community will make use of this blog.