Skip to content

Instantly share code, notes, and snippets.

@nuit
Last active August 29, 2015 13:55
Show Gist options
  • Save nuit/8700837 to your computer and use it in GitHub Desktop.
Save nuit/8700837 to your computer and use it in GitHub Desktop.
Project Euler Solution
import time
import math
start = time.time()
def primo(n):
if n%2==0: return False
return not any(n%i==0 for i in range(3, int(math.sqrt(n))+1,2))
sum = 0
for i in range(2, 2000000):
if primo(i):
sum += i
print 'sum:',sum+2
end = time.time()
timer = end-start
print "time:",timer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment