Write a function sumprimes(l) that takes as input a list of integers l and retuns the sum of all the prime numbers in l.
Answers
Answered by
2
#define sumprimes(l):
sum=0 ; //initialisation of sum
for value in l:
for i in range(1,float((value)/2)):
if value%i==0: //verifying if it is a prime number or not.
sum+=value; //sum=sum+value
print(sum);
This program will take the list of input from user and channelise the prime numbers and store the sum in every iteration.
Answered by
0
Answer:
Step-by-step explanation:
def prime(n):
count=0
if n>1:
for i in range(1,n+1):
if n%i==0:
count=count+1
if count==2:
return True
else:
return False
def sumprimes(l):
x = list(filter(prime,l))
y = sum(x)
return y
Similar questions