BC155 牛牛的素数和
思路:
step1:找到素数,创建计数器,累加打印;
代码如下:
def fn(m,n):
count = 0
for i in range(m,n+1):
x = 2
flag = True
while x <= i**0.5 + 1:
if i != 2 and i%x == 0:
flag = False
elif i == 2:
flag = True
x += 1
if flag:
count += i
print(count)
m,n = list(map(int,input().split()))
fn(m,n)