Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created Feb 21, 2021
Embed
What would you like to do?
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n;
cout<<"enter number :";
cin>>n;
bool flag = 0;
for(int i = 2; i<=sqrt(n); i++){
if (n%i == 0){
cout<<"Not a Prime Number";
flag = 1;
break;
}
}
if(flag == 0){
cout<<"Prime number"<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment