- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
public class main {
public static void main(String[] args) {
Boolean[] table = new Boolean[1000001];
for(int i=2; i<=1000000; i++) {
table[i]=true;
}
Boolean cont=true;
int p=2;
while(cont) {
for(int i=2; i<=1000000; i++) {
try{
table[p*i]=false;
}
catch(Exception e) {}
}
int find=2;
while(!table[find]) find++;
if(find==2) {cont=false; break;}
p=find;
}
for(int i=2; i<=1000000; i++) {
if(table[i]) System.out.println(i);
}
}
}