Hide

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 $n$ is prime or not, the function returns a boolean. See the attached code files.

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 $\ell $, converting each number to int, and pass it to your function.

Input

The function recieves one parameter, a list of integers $\ell $.

In the tests, $\ell $ will be of length $1 \le |\ell | \le 100$, each integer $\ell _i$ in the list will be restricted to $1 \le \ell _i \le 100\, 000$.

Output

The function should return the sum of all primes in the list $\ell $.

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

Please log in to submit a solution to this problem

Log in