def is_prime(num):
if num == 2:
return 1
for i in range(2, num):
if num % i == 0:
return 0
return 1
sum = 0
for i in range(2, 10):
if is_prime(i):
sum += i
print(sum)
def is_prime(num):
if num == 2:
return 1
for i in range(2, num):
if num % i == 0:
return 0
return 1
sum = 0
for i in range(2, 10):
if is_prime(i):
sum += i
print(sum)
本文标题:Python素数求和
本文链接:https://www.haomeiwen.com/subject/zathbctx.html
网友评论