Code below(corresponding to PRIME1) shows wrong answer in SPOJ. Works fine in IDEone with all the test cases that I have tried. Help needed...
include
using namespace std;
include
int checkprime(unsigned long int b)
{int x=sqrt(b);
for(int i=2;i<=x;++i)
{if(b%i==0 && b!=2)
return 0; }
return 1;
}
int main() {
int num;
unsigned long int m,n;
cin>>num;
for(int i=0;i<num;++i)
{ cin>>m>>n;
for(unsigned long int j=m;j<=n;++j)
if(checkprime(j))
cout<<j<<endl;
cout<<endl;
}
return 0;
}