Skip to content

Commit

Permalink
#2 : 1978_소수 찾기
Browse files Browse the repository at this point in the history
  • Loading branch information
yjhss committed Apr 12, 2023
1 parent 4b83916 commit 30a47d3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 이티유진/1978_소수 찾기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
n = int(input()) # 수의 개수 N 입력 받기
numbers = map(int, input().split()) # N개의 수 입력 받기
count = 0 # 소수의 개수를 세기 위한 변수 count 초기화

for num in numbers:
a = 0
if num > 1 :
for i in range(2, num): # 2부터 (num-1)까지 (자기자신 제외)
if num % i == 0:
a += 1 # 2와 (num-1) 사이 숫자로 나누어 떨어지면 a 1씩 증가
if a == 0:
count += 1 # a == 0 이면 소수이므로 count 1씩 증가
print(count)

0 comments on commit 30a47d3

Please sign in to comment.