What is error in code

its not printing for prime

@dipamagarwal7448,

If div by and no from 2 to n-1 then not prime

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

int main() {
int n;
cin>>n;
bool ans=true;

for(int i=2;i*i<=n;i++){
	if(n%i==0)ans=false;
}
if(ans)cout<<"Prime";
else cout<<"Not Prime";
return 0;

}
`

send your code or check this

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.