Skip to content

Instantly share code, notes, and snippets.

@soravux
Last active December 15, 2015 23:08
Show Gist options
  • Save soravux/5337633 to your computer and use it in GitHub Desktop.
Save soravux/5337633 to your computer and use it in GitHub Desktop.
Solution to the Project Euler problem #1 - For the multigrad blog (entry 2)
# Algorithm
from itertools import chain
sum(set(x for x in chain(range(5, 1000, 5), range(3, 1000, 3))))
# To benchmark it
import timeit
timeit.timeit(
"sum(set(x for x in chain(range(5, 1000, 5), range(3, 1000, 3))))",
setup="from itertools import chain",
number=10000
) / 10000.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment