-
-
Save reo91004/8a2f20dd2466929a4bb939d0c647da69 to your computer and use it in GitHub Desktop.
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
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