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