View Code
#include<stdio.h>
#define MAX 1000
int main()
{
int n,i,j;
static char a[MAX];
scanf("%d",&n);
for(i=2;i<=n;i++)
{
if(!a[i])
{
for(j=2*i;j<n;j+=i)
a[j]=1;
}
}
for(i=2;i<n;i++)
{
if(!a[i])
printf("%d\n",i);
}
return 0;
}