public class Sieb3a { public static void main(String args[]) { int i, j; boolean [] sieb = new boolean[1000001]; for (i=2; i<=1000000; i++) sieb[i]=true; for (j=4; j<=1000000; j+=2) sieb[j]=false; for (i=3; i<=1000; i++) if (sieb[i]==true) for (j=3*i; j<=1000000; j=j+2*i) sieb[j]=false; j=0; for (i=2; i<=1000000; i++) if (sieb[i]==true) j++; System.out.println("Anzahl der Primzahlen: " + j); System.exit(0); } }