Last active
August 29, 2015 14:23
-
-
Save luc99a/78a1498c4283e66108ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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