Skip to content

Commit 4f50527

Browse files
authored
Merge pull request larissalages#168 from kartikeysingh6/master
Solution to Code: PRIME1
2 parents 75d2bff + 8338af4 commit 4f50527

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <bits/stdc++.h>
2+
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
3+
typedef unsigned long long int unt;
4+
using namespace std;
5+
6+
bool Prime(unt n){
7+
8+
if (n <= 1)
9+
return false;
10+
if (n <= 3)
11+
return true;
12+
13+
if (n % 2 == 0 || n % 3 == 0)
14+
return false;
15+
16+
for (unt i = 5; i * i <= n; i = i + 6)
17+
if (n % i == 0 || n % (i + 2) == 0)
18+
return false;
19+
20+
return true;
21+
}
22+
23+
void printPrime(unt a,unt n){
24+
for (unt i = a; i <= n; i++){
25+
if(Prime(i))
26+
cout <<i<<'\n';
27+
}
28+
}
29+
30+
int main(){
31+
fast;
32+
unt t;
33+
cin>>t;
34+
while(t--){
35+
int a,n;
36+
cin>>a>>n;
37+
printPrime(a,n);
38+
}
39+
}

0 commit comments

Comments
 (0)