Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int prim (int x)
- { int i,cod=1;
- if(x==0 || x==1 || (x%2==0 && x!=2))
- cod=0;
- for(i=3;i*i<=x;i+=2)
- if(x%i==0)
- cod=0;
- if(cod==1) return 1;
- else return 0;
- }
- void P(int x[100],int n,int &s)
- {int s1;
- if(n==1)
- if(prim(x[n-1])==1) s=x[n-1];
- else s=0;
- else {
- P(x,n-1,s1);
- if(prim(x[n-1])==1) s=s1+x[n-1];
- else s=s1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement