Advertisement
Nevtr4l

Test de Primalidad (Fácil)

Mar 11th, 2025 (edited)
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | Source Code | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. bool esPrimo(long long  N) {
  6.   for (long long  div = 2; div * div <= N; div++) {
  7.     if (N % div == 0) {
  8.       return false;
  9.     }
  10.   }
  11.   return true;
  12. }
  13.  
  14. int main() {
  15.   int t; cin >> t;
  16.   while (t--) {
  17.     long long N; cin >> N;
  18.     cout << (esPrimo(N) ? "YES" : "NO") << endl;
  19.   }
  20.  
  21.   return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement