int i,n;
while(scanf("%d",&n)!=EOF)
{
for(i=2;i
int i,n,x;
while(scanf("%d",&n)!=EOF)
{
x=(int)sqrt(n);
for(i=2;i<=x;i++)
if(n%i==0) break;
if(i>x) printf("YES\n");
else printf("NO\n");
}
#include
#include
#define MAXN 100000
#define MAXL 1000000
_Bool check[MAXN];
int prime[MAXL];
int main(void)
{
int n,count;
while (~scanf("%d", &n))
{
count = 0;
memset(check, 0, sizeof(check));
for (int i = 2; i <= n; i++)
{
if (!check[i])
prime[count++] = i;
for (int j = i + i; j <= n; j += i)
check[j] = 1;
}
for (int i = 0; i < count; i++)
printf("%d\n", prime[i]);
}
return 0;
}
#include
#include
#define MAXN 100000
#define MAXL 1000000
int prime[MAXN];
_Bool check[MAXL];
int main(void)
{
int n, count;
while (~scanf("%d", &n))
{
memset(check, 0, sizeof(check));
count = 0;
for (int i = 2; i <= n; i++)
{
if (!check[i])
prime[count++] = i;
for (int j = 0; j < count; j++)
{
if (i*prime[j] > MAXL)
break; // 过大的时候跳出
check[i*prime[j]] = 1;
if ((i%prime[j]) == 0) // 如果i是一个合数,而且i % prime[j] == 0
break;
}
}
for (int i = 0; i < count; i++)
printf("%d\n", prime[i]);
}
return 0;
}