Advertisement
SergeyPGUTI

6.1.5

Oct 24th, 2015
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5.  bool IsPrime (int n)
  6. {
  7.     bool prost=true;
  8.     for (int i=2;i<=sqrt(n);i++)
  9.     {
  10.         if ((n % i)==0)
  11.         {
  12.             prost=false;
  13.             break;
  14.  
  15.         }
  16.     }
  17.  
  18. if (prost)
  19.     cout<<"prime";
  20. else cout<<"composite";
  21.  
  22. }
  23.  
  24. int main()
  25.  
  26. {
  27.     int n;
  28.     cin>>n;
  29.     IsPrime(n);
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement