I use a seive code for generating primes.I dont know if it is fast enough.If anyone have any idea to make my code faster then please help.Or give me a faster code so I can store that for later use.
Thanks in advance.
//function sieve begin:
#define Max 20000000
int prime_int[Max];
bool prime_bool[Max];
void prime_num()
{
int i,j,root=sqrt(Max);
for(i=4;i<=Max;i+=2)
prime_bool[i]=true;
for(i=3;i<=root;i+=2)
if(!prime_bool[i])
{
for(j=i*i;j<=Max;j+=2*i)
prime_bool[j]=true;
}
prime_int[0]=2;
for(i=3,j=1;i<Max;i+=2)
if(!prime_bool[i])prime_int[j++]=i;
}
//function sieve end