Untitled
raw download clone
TEXT
views 21
,
size 591 b
#include<iostream>
using namespace std;
int prim(int a)
{
    if(a<=1)
        return 0;
    else
        if(a%2==0&&a!=2)
            return 0;
        else
            for(int d=3;d*d<=a;d++)
                if(a%d==0)
                    return 0;
    return 1;
}
void P(int v[101],int n,int &s)
{
    if(n==1)
        if(prim(v[0])==1)
        {
            s=s+v[0];
        }
        else
            s=0;
    else
        if(prim(v[n-1])==1)
        {
            P(v,n-1,s);
            s=s+v[n-1];
        }
        else
            P(v,n-1,s);
}
close fullscreen
Login or Register to edit or fork this paste. It's free.