Skip to content

Instantly share code, notes, and snippets.

@reo91004
Created April 8, 2022 08:15
Show Gist options
  • Save reo91004/8a2f20dd2466929a4bb939d0c647da69 to your computer and use it in GitHub Desktop.
Save reo91004/8a2f20dd2466929a4bb939d0c647da69 to your computer and use it in GitHub Desktop.
arr = [False, False] + [True] * (246912 - 1)
i = 2
# 에라토스테네스의 체
while i <= 246912:
if arr[i]: # 지워나가는 과정
for j in range(i + i, 246912 + 1, i):
if arr[j]:
arr[j] = False
i += 1
while True:
N = int(input())
if (N == 0):
break
res = 0
for i in range(N + 1, 2 * N + 1):
if (arr[i]):
res += 1
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment