Algorithm/BOJ 기초

[백준] 2581 소수 Python (주어진 범위 내 소수들의 합, 최소값)

hackyu 2019. 10. 8. 06:34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
= int(input())
= int(input())
lists = []
 
for i in range(m, n+1):
    check = 0
    if i >= 2:
        if i == 2:
            lists.append(i)
        else:
            for j in range(2, i):
                if i%j == 0:
                    check = 1
                    break
            if check == 0:
                lists.append(i)
 
if len(lists) >= 1:
    print(sum(lists))
    print(min(lists))
else:
    print(-1)