<jupyter_start><jupyter_text>*This problem is taken from projecteuler.net<jupyter_code>"""
Multiples of 3 and 5
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.
"""
def solution1 (endpoint) : 
    odd_sum = 0
    even_sum = 0
    #Odd multiples can be found by checking the interval when step = 2  
    for num in range(3,endpoint,2) :
        #If the number is divisible by 3 or 5, it is added to the odd sum
        if num % 3 == 0 or num % 5 == 0 :
            odd_sum += num 
        
    #Even multiples which are either a multiple of 6 or 10 can be found via two for loops
    #One with step = 6, the other with step = 10
    for num in range (10,endpoint,10) : 
        even_sum += num

    for num in range(6,endpoint) : 
        #Numbers which are divisible by 10 are already added to even sum. Therefore, adding
        #them to the sum should be avoided.
        if num % 10 == 0 : 
            pass 
        elif num % 6 == 0 :
            even_sum += num 
            
    return even_sum + odd_sum
print(solution1(1000))<jupyter_output>233168<jupyter_text>Solution 2   Going to see the runtime difference on a more efficient code<jupyter_code>def solution2(endpoint) : 
    sumx = 0
    for num in range(3,endpoint) : 
        if num % 3 == 0 or num % 5 == 0 : 
            sumx += num 
            
    return sumx<jupyter_output><empty_output><jupyter_text>Code runtime  Processor : 2 GHz Quad-Core Intel Core i7  Performance comparison<jupyter_code>q = datetime.now()
print(solution1(10**8))
print("Solution-1 runtime : ", datetime.now()-q) 
q = datetime.now()
print(solution2(10**8))
print("Solution-2 runtime : ", datetime.now()-q)<jupyter_output>2333333316666668
Solution-2 runtime :  0:00:11.564603
{'fraction_non_alphanumeric': 0.08614232209737828, 'fraction_numerical': 0.05778491171749599, 'mean_word_length': 2.659491193737769, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '482862', 'license': 'MIT', 'n_tokens_mistral': 687, 'n_tokens_neox': 585, 'n_words': 234, 'path': 'Problems/Problem1.ipynb', 'repo_name': 'kutayeroglu/euler-project-solutions', 'size': '1869'}