#include <stdio.h>
#include <conio.h>
#define n 200000
int main()
{
short flag[n];
long int i,j,total;
for(i=1;i<=n;i++)
flag[i]=1;
i=2;
total=0;
flag[2]=0;
while(i<=n)
{
if (flag[i])
{
printf("%d ",i);
total++;
for(j=i+1;j<=n;j++)
if (j%i==0)
flag[j]=0;
}
i++;
}
printf("\nTotal:%ld",total);
getch();
return 0;
}
Views: 119