0

Write a function sumprimes(l) that takes as input a list of integers and retuns the sum of all the prime numbers in l.

10th Feb 2017, 4:31 PM
Kannan M
Kannan M - avatar
3 Antworten
+ 1
def sumprimes(n): sum=0 if n == 1: return False if n == 2: return True for i in range(0,len(n)): num=n[i] if num>1: pr=True for j in range(2,int(num**0.5)+1): if num%j == 0: pr= False break if pr: sum=sum+num else: sum=0 return sum
17th Aug 2018, 6:58 AM
abisek k
abisek k - avatar
0
Stop with your flood about other web-site/app task... Try it by yourself, you will never learn nothing by this way :P
10th Feb 2017, 4:33 PM
visph
visph - avatar
0
def sumprimes(n): sum=0 if n == 1: return False if n == 2: return True for i in range(0,len(n)): num=n[i] if num>1: pr=True for j in range(2,int(num**0.5)+1): if num%j == 0: pr= False break if pr: sum=sum+num else: sum=0 return sum
17th Aug 2018, 6:58 AM
abisek k
abisek k - avatar