Skip to content

Instantly share code, notes, and snippets.

@sota1235
Created August 13, 2014 09:59
Show Gist options
  • Save sota1235/020fc7b13993e1a106be to your computer and use it in GitHub Desktop.
Save sota1235/020fc7b13993e1a106be to your computer and use it in GitHub Desktop.
AOJ #0053
# 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