Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int a[100],n,x;
- int prim(int n)
- {
- if(n<=1) return 0;
- int i=2;
- while(i<=n/2)
- if(n%i==0)return 0;
- else i++;
- return 1;
- }
- int numara(int p,int u)
- { int m,n1,n2;
- if(u==p) if(prim(a[p])) return 1;
- else return 0;
- else
- {
- m=(p+u)/2;
- n1=numara(p,m);
- n2=numara(m+1,u);
- return n1+n2;
- }
- }
- int main()
- {
- cin>>n;
- for(int i=1;i<=n;i++)
- cin>>a[i];
- cout<<"numarul de numere prime="<<numara(1,n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement