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;
}
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