https://www.acmicpc.net/problem/1978
소수인지 아닌지를 boolean으로 판별하고 1과 자기 자신만을 포함해야하므로 그 외에 나눠지는 값이 존재한다면 소수가 아니므로 넘어간다.
import math
n = int(input())
arr = list(map(int, input().split()))
cnt = 0
for i in arr:
if i < 2:
continue
isPrime = True
for j in range(2, int(math.sqrt(i)) + 1):
if i % j == 0:
isPrime = False
break
if isPrime:
cnt += 1
print(cnt)
📚 소수 판별 알고리즘
isPrime = True for j in range(2, int(math.sqrt(i)) + 1): if i % j == 0: isPrime = False break
```