Skip to content

Commit

Permalink
[#3] 2021.12.20 백준단계별9.기본수학2 1~4
Browse files Browse the repository at this point in the history
  • Loading branch information
hyesuuou committed Dec 21, 2021
1 parent 3a9d0c6 commit e7a2186
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Boj/기본 수학2/11653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
n = int(input())

i = 2
while True:
if n % i == 0:
print(i)
n = n // i
else:
i = i + 1
if i > n:
break
18 changes: 18 additions & 0 deletions Boj/기본 수학2/1929.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
m, n = map(int, input().split())
list = []

for i in range(0, n+1):
list.append(i)
list[1] = 0

for i in range(2, n+1):
if list[i] == 0:
continue
j = 2
while i*j <= n:
list[i*j] = 0
j = j+1

for i in range(m, n+1):
if list[i] != 0:
print(list[i])
16 changes: 16 additions & 0 deletions Boj/기본 수학2/1978.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
n = int(input())
data = list(map(int, input().split()))
result = 0

for i in range(len(data)):
isPrime = True
if data[i] == 1:
continue
for j in range(2, data[i]):
if data[i] % j == 0:
isPrime = False
break
if isPrime:
result = result + 1

print(result)
26 changes: 26 additions & 0 deletions Boj/기본 수학2/2581.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
def isPrime(k):
if k == 1:
return False
for i in range(2, k):
if k % i == 0:
return False
return True


m = int(input())
n = int(input())
data = []

for i in range(m, n + 1):
if isPrime(i):
data.append(i)

if len(data) == 0:
print(-1)
exit(0)

sum = 0
for i in range(len(data)):
sum = sum + data[i]
print(sum)
print(data[0])

0 comments on commit e7a2186

Please sign in to comment.