Created
August 13, 2014 09:59
-
-
Save sota1235/020fc7b13993e1a106be to your computer and use it in GitHub Desktop.
AOJ #0053
This file contains hidden or 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
# AOJ | |
# 0053 | |
# python3 | |
def sieve(n): | |
num = [True] * n | |
num[0] = num[1] = False | |
for i in range(2,int(n**0.5)+1): | |
if num[i]: | |
for j in range(i**2, n, i): | |
num[j] = False | |
return [i for i in range(2, n) if num[i]] | |
prime = sieve(110000) | |
while True: | |
n = int(input()) | |
if n == 0: break | |
print(sum(prime[:n])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment