John Lekberg


JUNTO Practice - "Project Euler Problem 1"

Discussed on 2018-09-18.

Project Euler Problem 1


Solution - Daniel

sum({*range(3, 1000, 3)} | {*range(5, 1000, 5)})

Solution - John

sum(i for i in range(1000) if not (i % 5 and i % 3))

Solution - Oscar

# -*- coding: utf-8 -*-
"""
Created on Thu Sep  6 12:16:50 2018

@author: omartinez
"""

#%% JUNTO Practice Problem 3
# We want to find the sum of the multiples of 3 or 5 in a range, [1,N)
# In this case N is 1000, range is [1,1000)

# We opt to store the values in an array and then sum them,
# in case we wanted to list the numbers
# Start with empty array
arr_multiples = []

# Loop through [1,1000)
# Check if remainder is 0, the number is a multiple and we store it
for i in range(1, 1000):
    if i % 3 == 0 or i % 5 == 0:
        arr_multiples.append(i)

arr_multiples
sum(arr_multiples)