Skip to content

Commit

Permalink
[boj] 1978 mod - wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
haremeat committed Nov 12, 2021
1 parent 3be6d38 commit 1b02807
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions boj/1978.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,48 @@
# 소수 찾기

# 기본적인 소수 판별 함수
# def is_prime_number(x):
# for i in range(2, x):
# if x % i == 0:
# return False
# return True


# 틀림.. why?



# def check(num):
# if num == 1:
# return False
# elif num == 2:
# return True
# for i in range(2, num + 1):
# if num % i == 0:
# return False
# return True

# 에라토스테네스의 체
import math

n = int(input())
sosu = list(map(int, input().split()))
count = 0

def check(num):
if num == 1:
return False
elif num == 2:
return True
for i in range(2,num+1):
if num % i == 0:
return False
return True
def is_prime_number(num, arr):
flag = 0
count = 0

for i in arr:
if i > 1:
for j in range(2, int(math.sqrt(i)) + 1):
if i % j == 0:
flag += 1
if flag == 0:
count += 1

return count

for i in sosu:
if check(i):
count += 1

print(count)
print(is_prime_number(n, sosu))

# 틀림..

0 comments on commit 1b02807

Please sign in to comment.