1 package test ;
2 import java.util.Scanner ;
3 public class hello
4 {
5 public static void main(String [] args)
6 {
7 Scanner read = new Scanner(System.in);
8 while(read.hasNext())
9 {
10 String rr = read.next();
11 int maxn=Integer.parseInt(rr);
12 boolean isprime[] = new boolean [maxn] ; //Java 默认初始化值为false
13 // int prime[] =new int [maxn/3];
14 int i,j;
15 for( i=2 ; i<maxn ; i++ )
16 {
17 if(!isprime[i])
18 {
19 for(j=i+i ;j<maxn ;j+=i)
20 isprime[j]=true;
21 }
22 }
23 for(i=2 ;i<maxn ;i++)
24 {
25 if(!isprime[i])
26 System.out.print(" "+i);
27 }
28 System.out.println();
29 }
30 }
31 }