fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10.  
  11. public static boolean isPrime (int a) {
  12. int sr = (int) java.lang.Math.sqrt(a);
  13. for (int i = 2; i <= sr; i++) {
  14. if (a%i == 0) {
  15. return false;
  16. }
  17. }
  18.  
  19. return true;
  20.  
  21. }
  22. public static void main (String[] args) throws java.lang.Exception
  23. {
  24. Scanner scan = new Scanner(System.in);
  25. int a = scan.nextInt();
  26. System.out.println(isPrime(a));
  27. }
  28. }
Success #stdin #stdout 0.13s 51452KB
stdin
10
stdout
false