Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int primul(int a)
- {
- for( int i=2; i<=a; i++)
- if(a%i==0)
- return i;
- }
- int main()
- {
- int x, max=0, i, n, a[6], j, b, ct=0,c;
- cin>>x;
- cout<<"Cel mai mic divizor al nr a este: "<<primul(x)<<endl;
- cin>>n;
- for(i=0; i<n; i++)
- cin>>a[i];
- for(i=0; i<n; i++)
- {
- b=a[i]/primul(a[i]);
- c=b;
- for(j=1; j<=b; j++)
- if(b%j==0)
- ct++;
- if(a[i]==primul(a[i])*c && a[i]>max && ct==2)
- max=a[i];
- ct=0;
- }
- if(max!=0)
- cout<<"DA"<<" "<<max;
- else
- cout<<"NU";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement