fork(4) 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. static int oddcnt;
  11.  
  12. public static void checkprime(int x) {
  13. for (int i=3; i <= Math.sqrt(x); i +=2)
  14. if ((x % i) == 0)
  15. return;
  16. oddcnt++;
  17. }
  18.  
  19.  
  20. public static void genodd(int x, int curlen, int maxlen) {
  21. x *= 10;
  22. for (int i=1; i<10; i+=2) {
  23. int nx = x + i;
  24. checkprime(nx);
  25. if (curlen < maxlen)
  26. genodd(nx, curlen + 1, maxlen);
  27. }
  28. }
  29.  
  30. public static void main (String[] args) throws java.lang.Exception
  31. {
  32.  
  33. genodd(0, 1, 8);
  34. System.out.println(oddcnt);
  35. }
  36. }
  37.  
Success #stdin #stdout 0.74s 2249728KB
stdin
Standard input is empty
stdout
56867