백준 1978번 소수찾기 (파이썬)
2022. 1. 27. 19:28ㆍ파이썬/백준
내 코드
n=int(input())
test=tuple(map(int,input().split()))
sosu=[]
for i in test:
c=2
while c<i:
if i%c==0:
break
if c==i-1:
sosu.append(i)
c+=1
print(len(sosu))
내 첫코드
근데 틀렸다. 왤까...
2를 생각 못 하고 있었다...
n=int(input())
test=tuple(map(int,input().split()))
sosu=0
for i in test:
if i==2:
sosu+=1
c=2
while c<i:
if i%c==0:
break
if c==i-1:
sosu+=1
c+=1
print(sosu)
2일때의 조건을 추가해주니 맞았다!!
'파이썬 > 백준' 카테고리의 다른 글
백준 11653번 소인수분해 (파인썬) (0) | 2022.02.05 |
---|---|
백준 2581번 소수 (파이썬) (0) | 2022.02.05 |
백준 1011번 Fly me to the Alpha Centauri (파이썬) (0) | 2022.01.26 |
백준 2839번 설탕 배달 (파이썬) (0) | 2021.03.11 |
백준 2775번 부녀회장이 될테야 (파이썬) (0) | 2021.03.10 |