본문 바로가기

Algorithm/BOJ 기초

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

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)

'Algorithm > BOJ 기초' 카테고리의 다른 글

[백준] 10773 제로 Python C++  (0) 2019.10.08
[백준] 11047 동전0 Python C++  (0) 2019.10.08
[백준] 소수찾기 1978 Python C++  (0) 2019.10.08
[백준] 2921 도미노 Python  (0) 2019.10.08
[백준] 주사위 세개 2480 Python C++  (0) 2019.10.04