Notice
Recent Posts
Recent Comments
Link
Star_project
2. 자료구조와 알고리즘 입문 7. 소수(에라토스테네스 체) 본문
7. 소수(에라토스테네스 체)
import sys
sys.stdin=open("pythonalgorithm/섹션 2/7. 소수(에라토스테네스 체)/in4.txt", 'rt')
n=int(input())
ch=[0]*(n+1)
cnt=0
for i in range(2,n+1):
if ch[i]==0:
cnt+=1
for j in range(i, n+1, i):
ch[j]=1
print(cnt)
'코딩테스트 > Python' 카테고리의 다른 글
[인프런] 2. 자료구조와 알고리즘 입문 8. 뒤집은 소수 (0) | 2022.07.12 |
---|---|
[프로그래머스] 자릿수 더하기 (0) | 2022.07.11 |
2. 자료구조와 알고리즘 입문 6.자릿수의 합 (0) | 2022.07.11 |
2. 자료구조와 알고리즘 입문 4. 대표값 (0) | 2022.07.11 |
2. 자료구조와 알고리즘 입문 03.K번째 큰 수 (0) | 2022.07.11 |