-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprime_range1.cpp
More file actions
48 lines (41 loc) · 779 Bytes
/
Copy pathprime_range1.cpp
File metadata and controls
48 lines (41 loc) · 779 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
44
45
46
47
48
// https://youtu.be/sVdGn8xfCCM?list=PL-Jc9J83PIiFj7YSPl2ulcpwy-mwj1SSk
//Check for prime in Range [Naive Method]
#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;
bool checkPrime(int n)
{
//this function checks for prime
if(n==1)
return false;
for(int i=2;i*i<=n;i++)
{
if(n%i==0)
return false;
}
return true;
}
int main()
{
int low,high;
cin>>low>>high;
for(int i=low;i<=high;i++)
{
if(checkPrime(i))
cout<<i<<" ";
}
}