-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprime2.cpp
More file actions
43 lines (37 loc) · 798 Bytes
/
prime2.cpp
File metadata and controls
43 lines (37 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// https://youtu.be/HXSfAyjWM8A?list=PL-Jc9J83PIiFj7YSPl2ulcpwy-mwj1SSk&t=469
#include<iostream>
#include<fstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<queue>
#include<deque>
#include<utility>
#include<unordered_map>
#include<set>
#include<map>
#include<unordered_set>
#include<string>
#include<limits.h>
using namespace std;
#define ll long long int
const int mod=1e9+7;
int main()
{
//This is a better than the previous one
int n;
cin>>n; // To Check if n is prime or not
int count=0;
for(int i=2;i*i<=n;i++)
{
if(n%i==0)
{
count++;
break; // when the first number also divided then it is not prime
}
}
if(count==0 && n!=1)
cout<<"Prime\n";
else
cout<<"Not-Prime\n";
}