unsigned long prime[6543];//65535内有6542个素数
void initprime(void);
int isprime(unsigned long x){
unsigned long i;
initprime();
for(i=0;prime[i]*prime[i]<=x;++i)
if(x%prime[i]==0)return 0;
return x>1;
}
void initprime(void){
unsigned short i;
static unsigned short top=0;
if(top)return;
for(prime[top++]=2,i=3;;){
if(isprime(i))prime[top++]=i;
if(++i==0)break;
}
}