https://www.codechef.com/viewsolution/30969902

Getting WA even if all test cases seem to be right .Help

Your prime function is wrong. Try

```
1
1 2
```

Also please use proper indentation. It helps keep the code understandable and easy to debug.

2 Likes

#include

using namespace std;

int prime(int n)

{

for(int i=2;i<=n/2;i++)

{

if(n%i==0)

return false;

}

return true;

}

int main()

{

int t,x,y;

cin>>t;

while(t–){

cin>>x>>y;

int m=1;

while (!prime(x+y+m))

{

m++;

}

cout<<m<<endl;

}

return 0;

}

what needs to be improved because error persists

As @everule1 pointed out your prime function is wrong and obviously the error would persist because your prime function is still wrong man.

Try again to find what is the error in your prime function.

Let me give you a hint, why are you iterating till n /2.

1 Like