Advertisement
fahimkamal63

Prime number tester

Apr 10th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. int main(){
  6.     int t; cin >> t;
  7.     while(t--){
  8.         int n, i;
  9.         cin >> n;
  10.         int flag = 1;
  11.         for(i = 2; i <= sqrt(n); i++){
  12.             if(!(n % i)){
  13.                 flag = 0;
  14.                 break;
  15.             }
  16.         }
  17.         if(flag) cout << "Yes\n";
  18.         else cout << "No\n";
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement