Problem in submittion of problem PRB01

int main()
{
    long long int t,a,i,flag;
    cin>>t;
    while(t--)
    {
        cin>>a;
        flag=1;
        for(i=2;i<sqrt(a);i++)
            {
                if(a%i==0)
                flag=0;
            }
    if(flag==1)
        cout<<"yes\n";
    else
        cout<<"no\n";
    }
}

This program is not get submitted PRB01 can anyone say whats the problem?

Bro your code is wrong output for a==1 and for loop till sqrt(n)
See below My Code:
#include
#include<bits/stdc++.h>
using namespace std;
bool premility(long long int n)
{
if(n==1)
return false;
else{
for(int i=2;i<=sqrt(n);i++)
{
if(n%i==0)
return false;
}
return true;
}
}
int main()
{
long long int t,a,i,flag;
cin>>t;
while(t–)
{
cin>>a;
if(premility(a))
cout<<“yes\n”;
else
cout<<“no\n”;
}
}

1 Like

Thanks bro
Than you for the help now i can understand the problem much better. :grin: