Tuesday, 20 September 2016

Sum Of Prime

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


def sumprimes(l):
    sum=0
    for i in range(len(l)):
      if l[i]>0:
        j=i
        flag=0
        for k in range(2,l[i]):
            if l[j]%k==0:
                flag=1
                break
        if flag==0:
           sum=sum+l[j]

    return sum

1 comment:

  1. JackpotCity Casino: Now Open! | Jammy Global Casino
    JackpotCity Casino New Jersey 정읍 출장마사지 is now open! We are open and excited to welcome you back to a 충주 출장샵 world 당진 출장마사지 in the palm of 문경 출장안마 your hand. 남양주 출장안마

    ReplyDelete