Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- bool P(int x)
- {
- for(int d=2; d<=x/2; d++)
- if(x%d==0) return false;
- else return true;
- }
- int main()
- {
- int n;
- cout<<"n="; cin>>n;
- if(P(n)) cout<<"YES";
- else cout<<"NO";
- return 0;
- }
- //===========================
- #include<iostream.h>
- int Sum(int x)
- {
- int s=0;
- for(int d=2; d<=x/2; d++)
- if(x%d==0) s=s+d;
- return s;
- }
- int main()
- {
- int n;
- cout<<"n="; cin>>n;
- if(n==Sum(n)) cout<<"YES";
- else cout<<"NO";
- return 0;
- }
- //===========================
- #include<iostream.h>
- int NOD(int a, int b)
- {
- int r=a%b;
- while(r>0)
- {
- a=b;
- b=r;
- r=a%b;
- }
- return b;
- }
- int main()
- {
- int n; int k;
- if(NOD(n,k)=1) cout<<"YES";
- else cout<<"NO";
- return 0;
- }
- //===========================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement