I tried to consider above stated ideas....and impleamented the following code...
But still get the same result...
#include <stdio.h>
int main()
{
int test; // for Number of test cases.
long unsigned int a,b,i,c; // a first number, b second limit
scanf("%d",&test);
for(;test;test--)
{
scanf("%lu%lu",&a,&b); //we have to find prime numbers between a and b
for(;a<=b;a+=2)
{
c=0; //putting c=0 number is prime else not
if(a<2 || ( !(a%2) && a!=2) )
a++; //if a is 1 or (even but not 2) increment by 1
if(a==2)
{
printf("2\n");
if(b==2) //if upper limit is 2, don't print 3
break;
a++;
}
for(i=3;i<=( (a/2)+ 1);i+=2)
{
if(!(a%i)) //for loop is chekcing for prime upto (a/2)+1
{
c=1;
break;
}
}
if(!c)
printf("%lu\n",a); //print if c==0 else continue.
}
}
}
Help me, Waiting for Replies...
Where am I slow?? This code is teasing my mind.