Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # My First Successful Attempt (made by self)
- def multiples(x,r):
- ans = 0
- i = 0
- ret = []
- while True:
- ans = i * x
- if ans in range(r):
- ret.append(ans)
- else:
- return ret
- break
- i += 1
- print(sum(list(set(multiples(3,1000) + multiples(5,1000)))))
- # My Second Successful Attempt (used some help)
- print(sum([i for i in range(1, 1000) if any(i % factor == 0 for factor in [3, 5])]))
- # My Third Successful Attempt (made by self)
- a=[]
- for factor in [3,5]:
- for l in range(1,1000):
- if l%factor==0:
- a.append(l)
- print(sum(list(set(a))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement