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. static final int MAX=100;
  11.  
  12. public static void main(String[] args) throws NumberFormatException, IOException {
  13.  
  14.  
  15. sievedPrime();
  16. }
  17.  
  18.  
  19. private static void sievedPrime(){
  20. int root=(int) Math.sqrt(MAX)+1;
  21. int limit=(MAX-1)/2;
  22. boolean[] isPrime=new boolean[limit];
  23. Arrays.fill(isPrime, true);
  24. root = root/2 -1;
  25. for(int i = 0; i < root ; i++){
  26. if(isPrime[i]){
  27. for( int j = 2*i*(i+3)+3 , p = 2*i+3; j < limit ; j=j+p ){
  28. isPrime[j]=false;
  29. }
  30. }
  31. }
  32.  
  33. for(boolean b: isPrime)System.out.print(b);
  34. }
  35. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
truetruetruefalsetruetruefalsetruetruefalsetruefalsefalsetruetruefalsefalsetruefalsetruetruefalsetruefalsefalsetruefalsefalsetruetruefalsefalsetruefalsetruetruefalsefalsetruefalsetruefalsefalsetruefalsefalsefalsetruefalse