Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<iostream.h>
  2. bool P(int x)
  3. {
  4. for(int d=2; d<=x/2; d++)
  5. if(x%d==0) return false;
  6. else return true;
  7. }
  8. int main()
  9. {
  10. int n;
  11. cout<<"n="; cin>>n;
  12. if(P(n)) cout<<"YES";
  13. else cout<<"NO";
  14. return 0;
  15. }
  16. //===========================
  17. #include<iostream.h>
  18. int Sum(int x)
  19. {
  20. int s=0;
  21. for(int d=2; d<=x/2; d++)
  22. if(x%d==0) s=s+d;
  23. return s;
  24. }
  25. int main()
  26. {
  27. int n;
  28. cout<<"n="; cin>>n;
  29. if(n==Sum(n)) cout<<"YES";
  30. else cout<<"NO";
  31. return 0;
  32. }
  33. //===========================
  34. #include<iostream.h>
  35. int NOD(int a, int b)
  36. {
  37. int r=a%b;
  38. while(r>0)
  39. {
  40. a=b;
  41. b=r;
  42. r=a%b;
  43. }
  44. return b;
  45. }
  46. int main()
  47. {
  48. int n; int k;
  49. if(NOD(n,k)=1) cout<<"YES";
  50. else cout<<"NO";
  51. return 0;
  52. }
  53. //===========================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement