题解 | #牛牛的素数和#
牛牛的素数和
https://www.nowcoder.com/practice/d748d79f68ab443482c5547d93824f50
def is_prime(num): if num < 2 : return False for i in range(2,num): if num % i == 0: return False return True def prime_sum_and_list(l,r): prime_sum = 0 prime_list = [] for item in range(l,r+1): if is_prime(item): prime_sum += item prime_list.append(item) return prime_sum,prime_list a,b = map(int,input().split()) prime_sum, prime_list = prime_sum_and_list(a, b) print(prime_sum) # print(prime_list)