Answer is correct still the status showing wrong answer

Question-:CodeChef: Practical coding for everyone
Code-:CodeChef: Practical coding for everyone

I get “Access Denied” for your solution link.

try this-:CodeChef: Practical coding for everyone
OR
#include
using namespace std;

int main() {
// your code goes here
int n;
cin>>n;
int flag=0;
if(n==1)
flag=1;
for(int i=2;i<=n/2;i++)
{
if(n%i==0)
flag=1;
break;
}
if(flag==0)
cout<<“1”<<endl;
else
cout<<“0”<<endl;
return 0;
}

Access Denied.

HELP PLEASE - #9 by ssjgz :slight_smile:

when u r checking the condition of n%i==0 then u need to make the flag variable as 1 and break from the loop simultaneously only if that condition is true.so u need to put both the statements in curly braces as shown below:

#include<bits/stdc++.h>
using namespace std;

int main() {
// your code goes here
int n;
cin>>n;
int flag=0;
if(n==1)
flag=1;
for(int i=2;i<=n/2;i++)
{
if(n%i==0)
{
flag=1;
break;
}
}
if(flag==0)
cout<<“1”<<endl;
else
cout<<“0”<<endl;
return 0;
}

Sorry!.. My silly mistake :sweat_smile: :sneezing_face: