DEV Community

Discussion on: Project Euler #1 - Multiples of 3 and 5

Collapse
 
r0f1 profile image
Florian Rohrer

Python

print(sum(i for i in range(1001) if i % 3 == 0 or i % 5 == 0))
Collapse
 
r0f1 profile image
Florian Rohrer

For fun: A shorter solution.

sum({*range(3, 1000, 3)} | {*range(5, 1000, 5)})
Collapse
 
aswathm78 profile image
Aswath KNM

Great solution. Since I lost touch of python it was a little difficult. Now I understand.