Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created February 21, 2021 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/03ba69da4926bed61e50dcabaf19a884 to your computer and use it in GitHub Desktop.
Save amankharwal/03ba69da4926bed61e50dcabaf19a884 to your computer and use it in GitHub Desktop.
#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