My answer matches the required answer still the status showing wrong answer

(QUESTION)-:PRB01 Problem - CodeChef
#include
using namespace std;

int main()
{
// your code goes here
int T,flag=0;
int n;
cin>>T;
for(int i=1;i<=T;i++)
{
cin>>n;

    for(int j=2;j<n/2;j++)
    {
         flag=0;
       if(n%j==0)
        {
           cout<<"NO"<<endl;
           flag=1;
           break;
           
       }
    }

       if(flag==0)
       
           cout<<"YES"<<endl;
       
           
           
       
 }

return 0;

}

Help :sneezing_face:

consider the test case:

1
1

1 is not a prime number!

And please format or (better) post the link to your submission next time!

1 Like

:disappointed:

You Can Try This

#include <math.h>

using namespace std;

int isthisprime(long r){
	if (r==2)
		return 1;
	else if (r==1 || r==0 || r%2==0)
		return 0;
	else
		for (int i=3;i<int(sqrt(r))+1;i+=2)
			if(r%i==0)
				return 0;
	return 1;
}

int main(){
	int a;
	cin >> a;
	while(a--){
		long t;
		cin >> t;
		if(isthisprime(t))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

And Also Please Format You Code Just Surround Your Code With Three (```) At Start And At End

Thanks :grinning: