Skip to content

Instantly share code, notes, and snippets.

@luc99a
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luc99a/78a1498c4283e66108ae to your computer and use it in GitHub Desktop.
Save luc99a/78a1498c4283e66108ae to your computer and use it in GitHub Desktop.
def get_multiples(l, n):
result = []
for i in l:
if i % n == 0:
result.append(i)
return result
def union(l, m):
for i in l:
if i not in m:
m.append(i)
return m
def sum_list(l):
total = 0
for i in l:
total += i
return total
l = range(1, 1000)
multiples = union(get_multiples(l, 3), get_multiples(l, 5))
print(sum_list(multiples))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment