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.
2 parents 75d2bff + 8338af4 commit 4f50527Copy full SHA for 4f50527
CodeChef_problems/PrimeGenerator(PRIME1).cpp
@@ -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
15
16
+ for (unt i = 5; i * i <= n; i = i + 6)
17
+ if (n % i == 0 || n % (i + 2) == 0)
18
19
20
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