Created
January 28, 2014 01:46
-
-
Save tbrittoborges/8661014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
%timeit sum_prime(7919)
10 loops, best of 3: 152 ms per loop