Problem E
Sum of Primes
Write a function, prime_sum, that takes a list of integers and returns the sum of all prime numbers in the list.
Hint: using list comprehensions here could prove to be useful. Additionally you should take a look at some of the list functions available.
You are given the function is_prime(n) to check whether a given number
The main file, which handles input and output, is already provided. - Please only submit your function definitions, without any code outside the functions!
In the samples below, the first and only line of the input
contains a sequence of integers each sperated by a comma. The
main file provided will take this sequence, split it into the
list
Input
The function recieves one parameter, a list of integers
In the tests,
Output
The function should return the sum of all primes in the list
In the samples below, the first and only line of the output contains this sum.
Sample Input 1 | Sample Output 1 |
---|---|
1,2,3,4,5,6,7,8,9,10,11 |
28 |
Sample Input 2 | Sample Output 2 |
---|---|
4,6,12,32 |
0 |
Sample Input 3 | Sample Output 3 |
---|---|
2,4,6,12,32,64,120 |
2 |