Browse Source

Add 'F.cpp'

webturing 4 years ago
parent
commit
a6d4589c3d
1 changed files with 21 additions and 0 deletions
  1. 21 0
      F.cpp

+ 21 - 0
F.cpp

@@ -0,0 +1,21 @@
+#include<bits/stdc++.h>
+using namespace std;
+int Primer(int n) {
+    if(n < 2)return 0;
+    if(n == 2)return 1;
+    if(n % 2 == 0)return 0;
+    for(int i = 3; i * i <= n; i += 2) {
+        if(n % i == 0)return 0;
+    }
+    return 1;
+}
+int main(){
+    int n;cin>>n;
+    if(Primer(n)){
+        cout<<"Prime!";
+    }else{
+        cout<<"Not Prime!";
+    }
+     
+    return 0;
+}