Skip to content

Instantly share code, notes, and snippets.

@tbrittoborges
Created January 28, 2014 01:46
Show Gist options
  • Save tbrittoborges/8661014 to your computer and use it in GitHub Desktop.
Save tbrittoborges/8661014 to your computer and use it in GitHub Desktop.
def is_prime(N):
for x in xrange(2, N):
if N % x == 0:
return False
return True
def sum_prime(N):
return sum(x for x in xrange(N) if is_prime(x))
@tbrittoborges
Copy link
Author

%timeit sum_prime(7919)
10 loops, best of 3: 152 ms per loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment