1 #include<stdio.h>
2 #include<algorithm>
3 #include<string.h>
4 bool a[2000001];
5 int main()
6 {
7 int i,j,n;
8 memset(a,0,sizeof(a));
9 for(i=2;i*i<2000001;i++)
10 if(a[i]==0)
11 for(j=i+i;j<2000001;j+=i)
12 a[j]=1;
13 while(scanf("%d",&n),n)
14 {
15 for(i=2;i<=n;i++)
16 if(!a[i])
17 printf("%d ",i);
18 printf("
");
19 }
20 return 0;
21 }