Advertisement
inhuman_Arif

Loop 2

Sep 29th, 2021
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5.  
  6. int main()
  7. {
  8.     #ifndef ONLINE_JUDGE
  9.         freopen("input.txt", "r", stdin);
  10.         freopen("output.txt", "w", stdout);
  11.     #endif
  12.  
  13.     int n;
  14.     cin >> n;
  15.     bool flag=true;
  16.     for(int i=2;i<n/2;i++)
  17.     {
  18.         if(n%i==0)
  19.         {
  20.             flag = false;
  21.             break;
  22.         }
  23.     }
  24.     if(flag)
  25.         printf("%d is a prime number\n",n);
  26.     else
  27.         printf("%d is not a prime number\n",n);
  28.    
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement