fork download
  1. #include <iostream>
  2. using namespace std;
  3. bool prime(int n) {
  4. if (n < 2) return false;
  5. for (int x = 2; x*x <= n; x++) {
  6. if (n%x == 0) return false;
  7. }
  8. return true;
  9. }
  10.  
  11. int main() {
  12. int n;
  13. cin>>n;
  14. if(prime(n)){
  15. cout<<"YES";
  16. }else{
  17. cout<<"NO";
  18. }
  19. }
Success #stdin #stdout 0s 5320KB
stdin
4
stdout
NO