본문 바로가기
파이썬/백준

2581번 : 소수

by L_SU 2022. 7. 6.
# 백준 2581번 소수
M = int(input())
N = int(input())
result = []
for i in range(M, N+1):
    no = 0
    if i > 1:
        for j in range(2, i):
            if i % j == 0:
                no = 1
                break
        if no == 0:
            result.append(i)
if len(result) > 0:
    print(sum(result))
    print(result[0])
else:
    print(-1)

'파이썬 > 백준' 카테고리의 다른 글

11727번 : 2Xn 타일링 2  (0) 2022.07.08
1924번 : 2007년  (0) 2022.07.07
9085번 : 더하기  (0) 2022.07.03
1037번 : 약수  (0) 2022.06.20
10872번 : 팩토리얼  (0) 2022.06.19