Advertisement
Egor_1425

Untitled

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