-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.cpp
More file actions
73 lines (72 loc) · 2.12 KB
/
Copy path2.cpp
File metadata and controls
73 lines (72 loc) · 2.12 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <math.h>
#include <fstream>
using namespace std;
int main(){
cout << "DPZK Prime Program" << endl ;
cout << "PLEASE INPUT AS INTRODUCTION" << endl << "FAILED TO DO SO MAY CAUSE INFINITE LOOP" << endl;
while(1){
unsigned long long int r1, r2,x=2;
ofstream opt("output.txt", ios::trunc);
//cin >> x;
cout << "Please input the range (0 to exit)" << endl;
cin >> r1;
if(r1==0){return false;}
cin >> r2;
//r1=1;r2=10000000;
bool n=true;
int c=0;
cout << "Starting Program:" ;
opt << "Prime from " <<r1 << "to " << r2 << endl ;
// if(r1<=2){
// r1=2;
// cout << "2" << " ";
// opt << "2" << " ";
//}
if(r1>10000){
x=sqrt(2*r1)*0.5;
//cout << "d;" <<x << " " << in << " ";
}
for(unsigned long long int in=r1;in<=r2;in++){
unsigned long long int q=in%6;
//cout << "d:"<<q<< " ";
if(in>5){
if(q==2){
n=false;
}else if(q==3){
n=false;
}else if(q==4){
n=false;
}
//if(!n){cout << "!";}
}
if(n){
//cout << "o" ;
for(unsigned long long int i=2;i<=in/x;i++){
//cout << "d:"<< i << " ";
if(in%i==0){
n=false;
break;
}
}
}
if(n){
cout << in << " ";
opt << in << " ";
c++;
}
if(c%300==0&&n==true){
x=sqrt(in*2)*0.5;
//cout << "d;" <<x << " " << in << " ";
}
n=true;
}
cout << endl << "Count is ";
opt << endl << "Count is ";
//if(r1<=2){c++;}
cout << c << endl;
opt << c << endl;
opt.close();
c=0;
}
}