We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 910b5c0 commit 2808129Copy full SHA for 2808129
6PrimeorNot
@@ -0,0 +1,32 @@
1
+// Online C++ compiler to run C++ program online
2
+
3
+#include <bits/stdc++.h>
4
+using namespace std;
5
6
+int main() {
7
+ // Write C++ code here
8
+ int n;
9
+ int flag=0;
10
+ cin>>n;
11
+ if(n==0||n==1||n==2){
12
+ cout<<"prime";
13
+ }
14
+ else if(n%2==0){
15
+ cout<<"not a prime number";
16
17
+ else{
18
+ for(int i=3;i<sqrt(n);i++){
19
+ if(n%i==0){
20
+ flag=0;
21
+ cout<<"not prime";
22
+ break;
23
24
+ flag=1;
25
26
+ if(flag==1){
27
28
29
30
31
+ return 0;
32
+}
0 commit comments