fork 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. public static boolean prim(int n) {
  11. int nr=0;
  12. int i;
  13. for(i=2;i<=n/2 && nr == 0;i++) {
  14. if(n%i==0) nr++;
  15. }
  16. if(nr==0) return true;
  17. return false;
  18.  
  19.  
  20. }
  21. public static void main (String[] args) throws java.lang.Exception
  22. {
  23. System.out.println(prim(5));
  24. }
  25. }
Success #stdin #stdout 0.1s 27784KB
stdin
Standard input is empty
stdout
true