Project Euler: Problem 1

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.


In [73]:
#creates function Addition with parameter my_numbers

def Addition(my_numbers):
    
    #creates a variable total to be used in the loop
    total = 0
    
#looping through every number
    for i in my_numbers:
        
        #Deciding if number meets parameters and if so, adds to "total"
        if i % 3 == 0 or i % 5 == 0:
            total += i
            
#returns "total"
    return total

#Calls on the funtion with a list of my_numbers = (1,2,3,4,...,999)
Addition(range(1,1000))



#For this program to properly execute, the only real required code is the total variable and the for loop. 
#(A my_numbers empty list  would be required as well). The purpose of the function is so the code will present a 
#user friendly answer. AKA print below this code.


Out[73]:
233168

In [62]:



  File "<ipython-input-62-48bc4a0e5c7c>", line 1
    print total
              ^
SyntaxError: invalid syntax

In [33]:
# This cell will be used for grading, leave it at the end of the notebook.

In [ ]:


In [ ]: