Untitled
raw download clone
TEXT
views 31
,
size 362 b
int prim(int x)
{
    if(x==0 || x==1)
        return 0 ;
    if(x%2==0&&x!=2)
        return 0 ;
    for(int d=3 ; d*d<=x ; d=d+2)
        if(x%d==0)
            return 0 ;
    return 1 ;
}

 void P(int x[] ,int n , int &s)
 {
    if(n==0) s=0;
    else
    {
        P(x,n-1,s);
        if(prim(x[n-1])==1)
            s=s+x[n-1];
    }
 }
close fullscreen
Login or Register to edit or fork this paste. It's free.