Created
April 18, 2012 07:52
-
-
Save hatashiro/2411842 to your computer and use it in GitHub Desktop.
Projecteuler #10
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
import math | |
def isPrime(num): | |
if num == 1: | |
return False | |
div = 2 | |
obj = num | |
sqrt = int(math.sqrt(num)) | |
while True: | |
if div > sqrt: | |
return True | |
if obj%div: | |
div = div + 1 | |
else: | |
return False | |
i = 1 | |
sum = 0 | |
while i <= 2000000: | |
if isPrime(i): | |
sum = sum + i | |
i = i + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment