fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6. int X = sc.nextInt();
  7. sc.close();
  8.  
  9. if (isPrime(X)) {
  10. System.out.println("YES");
  11. } else {
  12. System.out.println("NO");
  13. }
  14. }
  15.  
  16. public static boolean isPrime(int n) {
  17. if (n < 2) {
  18. return false;
  19. }
  20. for (int i = 2; i * i <= n; i++) {
  21. if (n % i == 0) {
  22. return false;
  23. }
  24. }
  25. return true;
  26. }
  27. }
  28.  
Success #stdin #stdout 0.11s 56632KB
stdin
7
stdout
YES